是否有与以下Microsoft API
等效的OpenSSL
(从private key
文件中提取.pfx
并另存为新文件)?
openssl pkcs12 -in mycert.pfx -nocerts -out mycert.key -passin pass:Password -passout pass:Password
答案 0 :(得分:0)
尝试一下:
RSACryptoServiceProvider rsa = (RSACryptoServiceProvider)YOUR_CERTIFICATE.PrivateKey;
MemoryStream memoryStream = new MemoryStream();
TextWriter streamWriter = new StreamWriter(memoryStream);
PemWriter pemWriter = new PemWriter(streamWriter);
AsymmetricCipherKeyPair keyPair = DotNetUtilities.GetRsaKeyPair(rsa);
pemWriter.WriteObject(keyPair.Private);
streamWriter.Flush();
string output = Encoding.ASCII.GetString(memoryStream.GetBuffer()).Trim();
int index_of_footer = output.IndexOf("-----END RSA PRIVATE KEY-----");
memoryStream.Close();
streamWriter.Close();
string PrivKey = output.Substring(0, index_of_footer + 29);