开发者

CryptAcquireCertificatePrivateKey - Create a permanent key container that accessing the certificate

How do i create a persistent key container u开发者_开发技巧sing cryptoAPI from a PFX self signed certificate?

I am able to access the private key in the PFX via CryptAcquireCertificatePrivateKey call but how do i import the private and public key pair in to a key container? This key container should be permanently present in the USER key store after completing the import process.

Looking forward for suggestions.

Thanks


One way is to import the certificate, and the key pair with respect of PFXImportCertStore.

Another way could be interesting for the understanding. You can save the key pair which you get with respect of the CryptAcquireCertificatePrivateKey in any new key container. Then you can import the certificate only (without the private key) and at the end you should set the container with the private key as the property of the certificate (CertSetCertificateContextProperty with CERT_KEY_PROV_INFO_PROP_ID).

In the practice one use always PFXImportCertStore function, but I recommend you to write a test program which you CertEnumCertificateContextProperties and look at the properties which will be saved together with the certificate in the certificate store, but which are not a part of the certificate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜