How to retrieve the private key of a certificate?
private string PrivateKey(X509Certificate2 certificate)
{
string pk;
if (certificate.PrivateKey != null)
{
RSACryptoServiceProvider rsaProvider = certificate.PrivateKey as RSACryptoServiceProvider;
pk = rsaProvider.CspKeyContainerInfo.UniqueKeyContainerName;
}
return pk;
}
{
string pk;
if (certificate.PrivateKey != null)
{
RSACryptoServiceProvider rsaProvider = certificate.PrivateKey as RSACryptoServiceProvider;
pk = rsaProvider.CspKeyContainerInfo.UniqueKeyContainerName;
}
return pk;
}
Comments
Post a Comment