gpt4 book ai didi

c# - 从 BouncyCaSTLe X509 证书获取私钥? C#

转载 作者:可可西里 更新时间:2023-11-01 09:17:22 27 4
gpt4 key购买 nike

通常,当我从我的 keystore 中获取一个 X509Certificate2 时,我可以调用 .PrivateKey 来检索证书的私钥作为 AsymmetricAlgorithm。但是我决定使用 Bouncy CaSTLe,它的 X509Certificate 实例只有一个 getPublicKey(); 我看不到从证书中获取私钥的方法。有什么想法吗?

我从我的 Windows-MY keystore 中获取 X509Certificate2,然后使用:

//mycert is an X509Certificate2 retrieved from Windows-MY Keystore
X509CertificateParser certParser = new X509CertificateParser();
X509Certificate privateCertBouncy = certParser.ReadCertificate(mycert.GetRawCertData());
AsymmetricKeyParameter pubKey = privateCertBouncy.GetPublicKey();
//how do i now get the private key to make a keypair?

是否可以将 AsymmetricAlgorithm(C# 私钥)转换为 AsymmetricKeyParameter(bouncycaSTLe 私钥)?

最佳答案

Akp = Org.BouncyCastle.Security.DotNetUtilities.GetKeyPair(this.Certificate.PrivateKey).Private;

关于c# - 从 BouncyCaSTLe X509 证书获取私钥? C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3240222/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com