BouncyCastle从现有密钥创建AsymmetricCipherKeyPair?

问题描述 投票:0回答:2

我有两个AssymetricAlgorithm RSA密钥,我从我的密钥库中的证书中提取出来。一个是公钥,另一个是私人。有没有办法将这个密钥对变成BouncyCastle AsymmetricCipherKeyPair? BouncyCastle的AsymmetricCipherKeyPair期望公共和私人AsymmetricKeyParameter然而我没有办法获得我的私钥而不是AssymetricAlgorithm的实例。

c# bouncycastle pki private-key
2个回答

1
投票

我认为如果将密钥标记为可导出,这将有所帮助

RSACryptoServiceProvider key = (RSACryptoServiceProvider)X509Certificate2object.PrivateKey;
RSAParameters rsaparam = key.ExportParameters(true);
AsymmetricCipherKeyPair keypair = DotNetUtilities.GetRsaKeyPair(rsaparam);
© www.soinside.com 2019 - 2024. All rights reserved.