通常情况下,当我从密钥库中获取一个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 私钥)?
Internal.Cryptography.CryptoThrowHelper.WindowsCryptographicException: 'The requested operation is not supported.'
。 - gakera