CryptAcquireCertificatePrivateKey - 创建访问证书的永久密钥容器
如何使用 PFX 自签名证书的 cryptoAPI
创建持久密钥容器?
我可以通过 CryptAcquireCertificatePrivateKey
调用访问 PFX 中的私钥,但如何将私钥和公钥对导入到密钥容器中?完成导入过程后,此密钥容器应永久存在于 USER 密钥存储中。
期待建议。
谢谢
How do i create a persistent key container using 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种方法是导入证书以及关于 PFXImportCertStore。
另一种方式对于理解可能会很有趣。您可以将通过
CryptAcquireCertificatePrivateKey
获得的密钥对保存在任何新的密钥容器中。然后您可以仅导入证书(没有私钥),最后您应该将带有私钥的容器设置为证书的属性(CertSetCertificateContextProperty 和CERT_KEY_PROV_INFO_PROP_ID
)。在实践中,始终使用 PFXImportCertStore功能,但我建议您编写一个测试程序 CertEnumCertificateContextProperties 并查看将与证书一起保存在证书存储中的属性,但它们不是证书的一部分。
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 withCERT_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.