Archived Forum Post

Index of archived forum posts

Question:

AddCertificate does not add private key to Windows store

Jul 06 '12 at 18:59

The AddCertificate command does not add the private key to the Windows Store. I use the LoadPfxFile command, with the correct password, and then the AddCertificate command. The certificate gets imported but without the private key. I want to import the private key also because i need SSL client authentication.


Answer

Correct. The Chilkat.CertStore.AddCertificate method only adds the certificate to the certificate store, but not the private key. Internally, it is calling the CryptoAPI function CertAddCertificateContextToStore (see http://msdn.microsoft.com/en-us/library/windows/desktop/aa376009%28v=vs.85%29.aspx )

The relatively undocumented Chilkat.Pfx class can be used to import a PFX (certs + private keys). See the reference documentation here: http://www.chilkatsoft.com/refdoc/csPFxRef.html