在C#中将ECC证书导入密钥库? [英] Import ECC Certificate into Key Store in C#?
问题描述
我有一个X509证书生成的EC密钥对需要导入到Windows中密钥库(当前用户或本地计算机)。 在我的尝试中,在C#中完成此操作的典型方法,即打开X509Store,从签名的X509Certificate和EC私钥创建X509Certificate2
,并将X509Certificate2添加到商店,不因使用EC键而工作;只需创建X509Certificate2就会生成一个SystemUnsupportedException,并显示消息"不支持证书
密钥算法。"
在网上看来,似乎我必须使用非托管API将ECC证书导入密钥库? 但是,作为Windows新手,我不太清楚从哪里开始。 任何帮助将不胜感激。 (顺便说一句,我使用BC生成
EC密钥对和证书)。
谢谢,
--Hyong
嗨hyongsop,
感谢您在此发帖。
我找到了一个与您的例外相同的线程并且问题已经解决,请参考它。
此外,您可以参考以下链接将证书导入窗口商店密钥库。
https://www.codeproject .com / Articles / 162194 /证书到数据库和返回
如果您有一个.cer文件,并且想要将其添加到X509Store中,您可以参考以下链接。
https:// msdn.microsoft.com/en-us/library/ms148583(v=vs.110).aspx
最好的问候,
温迪跨度>
Hi,
I have an X509 Certificate generated with an EC key pair that needs to be imported into a Windows Key Store (either current user or local machine). In my attempts so far, the typical way of accomplishing this in C#, i.e., open an X509Store, create a X509Certificate2 from the signed X509Certificate and EC private key, and add the X509Certificate2 to the store, doesn't work because of the use of the EC keys; just creating the X509Certificate2 generates a SystemUnsupportedException with the message of "the certificate key algorithm is not supported."
Looking on the web, it seems that I have to use unmanaged APIs to import ECC certificates into key stores? However, as a Windows newbie, I am not quite sure where to begin. Any help would be greatly appreciated. (Btw, I'm using BC to generate the EC key pair and certificate).
Thanks,
--Hyong
Hi hyongsop,
Thank you for posting here.
I found a thread which is the same as your exception and the problem has been resolved, please refer to it.
Besides, you could refer to the following link which imports Certificate into window store key store.
https://www.codeproject.com/Articles/162194/Certificates-to-DB-and-Back
If you have a .cer file and you want to add it into X509Store, you could refer to the following link.
https://msdn.microsoft.com/en-us/library/ms148583(v=vs.110).aspx
Best Regards,
Wendy
这篇关于在C#中将ECC证书导入密钥库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!