I need to read the private key, and this key is in pvk format. I use the X509Certificate2 class, but I am this class, I only have access to public keys. How can I get the private key from a pvk file?
Louis, you need to combine CER and PVK into one PFX file and then import the file as a certificate so that PrivateKey is available when you boot the X509Cert. See Decrypt PrivateKey X.509 Certificate .
http://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509certificate2.privatekey.aspx
How about this?
Keep in mind:
Currently, this property only supports RSA or DSA, so it returns either an RSACryptoServiceProvider or a DSACryptoServiceProvider Object. If there is no private key associated with the certificate, a null reference (Nothing in Visual Basic) is returned
You can use this command to combine them.
pvk2pfx -spc CA.cer -pvk CA.pvk -pfx CA.pfx
Decrypt with PrivateKey X.509 certificate