I had to use X509KeyStorageFlags. PersistKeySet | X509KeyStorageFlags. MachineKeySet flags to resolve the "Keyset does not exist" error that occurred later when trying to use the certificate:
X509Certificate2 certificate = new X509Certificate2(pfxPath, password, X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.MachineKeySet); using (X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine)) { store.Open(OpenFlags.ReadWrite); store.Add(certificate); store.Close(); }
Thanks to this article: the private key of the certificate in the certificate store is not readable
Dmitry Jul 05 '18 at 16:37 2018-07-05 16:37
source share