通常,当我从密钥库中X509Certificate2
取出一个密钥时,我可以调用.PrivateKey
以将证书的私钥检索为AsymmetricAlgorithm
. 但是我决定使用 Bouncy Castle,它的实例X509Certificate
只有一个getPublicKey();
我看不到从证书中获取私钥的方法。有任何想法吗?
我从我的 Windows-MY 密钥库中获得了 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私钥)?