无法在Windows7桌面上导入证书存储中的私钥

发布于 2024-10-02 12:24:41 字数 374 浏览 0 评论 0原文

我使用以下代码在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

新一帅帅 2024-10-09 12:24:41

检查您是否具有正确的权限:

如何设置对 .NET 的 X.509 证书的私钥文件的读取权限

您还可以尝试向证书构造函数添加存储标志:

X509Certificate2 certificate = new X509Certificate2("certFileName", "password", X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.MachineKeySet);

设置此权限可能会有所帮助:
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:

X509Certificate2 certificate = new X509Certificate2("certFileName", "password", X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.MachineKeySet);

Setting this permmission might help:
https://serverfault.com/questions/48124/disabling-strong-private-key-encryption-on-a-personal-certificate

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文