X509Certificate2 has a private key that is not exported?

In Win Server 2008, I can execute the code below, and when I try to export a certificate through the MMC GUI, I have no way to export the private key. However, if I use the GUI to import the certificate, I can also export the private key. What am I missing in my code?

string certfile = @"mycert.p12"; SecureString secString = new SecureString(); foreach (char c in "password") { secString.AppendChar(c); } X509Certificate2 cert = new X509Certificate2(certfile, secString, X509KeyStorageFlags.Exportable); var store = new X509Store(StoreName.My , StoreLocation.CurrentUser); store.Add(cert); 
+4
source share
1 answer

Yeah. Key storage flags must be exported and stored.

 X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet 
+9
source

All Articles