如何在 C# 中从 pvk 文件读取私钥?

发布于 2024-08-20 21:23:01 字数 87 浏览 5 评论 0原文

我必须读取一个私钥,该密钥是 pvk 格式的。我使用 X509Certificate2 类,但在这个类中我只有公钥访问权限。 如何从 pvk 文件中获取私钥?

I have to read a private key, and this key is on pvk format. I use X509Certificate2 class, but i this class i have only public key access.
How can I get a private key from pvk file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

静水深流 2024-08-27 21:23:01

Luiz,您需要将 CER 和 PVK 合并到一个 PFX 文件中,然后将该文件作为证书导入,这样当您加载 X509Cert 时,私钥就会在那里。请参阅使用 PrivateKey X.509 证书解密

Luiz, you need to combine the CER and PVK into a single PFX file, then import the file as a cert so that when you load the X509Cert the PrivateKey will be there. See Decrypt with PrivateKey X.509 Certificate.

一指流沙 2024-08-27 21:23:01

http://msdn.microsoft。 com/en-us/library/system.security.cryptography.x509certificates.x509certificate2.privatekey.aspx

这个怎么样?

请记住:

目前该属性仅支持
RSA 或 DSA 密钥,因此它返回
RSACryptoServiceProvider 或
DSACryptoServiceProvider 对象。如果没有
私钥与
证书,空引用(无
在 Visual Basic 中)返回

http://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509certificate2.privatekey.aspx

How about this ?

Have in mind:

Currently this property supports only
RSA or DSA keys, so it returns either
an RSACryptoServiceProvider or a
DSACryptoServiceProvider object. If no
private key is associated with the
certificate, a null reference (Nothing
in Visual Basic) is returned

一个人练习一个人 2024-08-27 21:23:01

您可以使用此命令将它们组合起来。

pvk2pfx -spc CA.cer -pvk CA.pvk -pfx CA.pfx

使用 PrivateKey X.509 证书解密

You can use this command to combine them.

pvk2pfx -spc CA.cer -pvk CA.pvk -pfx CA.pfx

Decrypt with PrivateKey X.509 Certificate

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