'How To Specify Security Principal (group or user) in X509Certificate2.Export() Instead of Password

Using the Certificates.msc tool, I can run the Certificate Export Wizard to export a SSL certificate to a .pfx file. This wizard allows me to either set a password, or to select a security principal (a group or user name). I choose the 2nd option and select a user name. Works great.

But I now want to do this same export programmatically, and I find that the X509Certificate2.Export() method only allows me to set a password. I see no way to use a security principal to protect the private key. How can I do that?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source