无法在Windows7桌面上导入证书存储中的私钥
我使用以下代码在 WinXp 桌面中导入带有密码/私钥的证书。
最近我迁移到 windows7,现在我无法导入私钥,尽管证书已导入到商店中。
这里可能出了什么问题?非常感谢任何帮助。
X509Store store = new X509Store(StoreName.My);
X509Certificate2 证书 = new X509Certificate2("certFileName", "password" ); store.Open(OpenFlags.ReadWrite);商店.添加(证书); store.Close()
注意到,即使我输入了错误的密码,证书仍然会被导入,并且私钥字段显然显示为空。但如果密码正确,它应该会被填充:-(
I used the following code to import certificate WITH the password/private key in WinXp desktop.
Recently I migrated to windows7 and now I am not able to import the private key, although the certificate gets imported in the store.
What could be wrong here ? Any help is deeply appreciated.
X509Store store = new X509Store(StoreName.My);
X509Certificate2 certificate = new X509Certificate2("certFileName", "password" ); store.Open(OpenFlags.ReadWrite); store.Add(certificate); store.Close()
Noticed that even if I type in the wrong password, the certificate still gets imported and private key field shows null, obviously. But with correct password it should get populated :-(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查您是否具有正确的权限:
如何设置对 .NET 的 X.509 证书的私钥文件的读取权限
您还可以尝试向证书构造函数添加存储标志:
设置此权限可能会有所帮助:
https://serverfault.com/questions/48124/disabling-个人证书上的强私钥加密
Check if you have correct permissions :
How to set read permission on the private key file of X.509 certificate from .NET
You can also try adding storage flags to the certificate constructor:
Setting this permmission might help:
https://serverfault.com/questions/48124/disabling-strong-private-key-encryption-on-a-personal-certificate