Cannot find the requested object. when creating X509certificate2

I am trying to create X509Certificate2 using a string private_keyusing the following code:

 byte[] key = Convert.FromBase64String(private_key);
 X509Certificate2 certificate = new X509Certificate2(key);

When the last line is executed, the following exception is thrown:

System.Security.Cryptography.CryptographicException Cannot find the requested object

Does anyone know how to solve this?

+4
source share
1 answer

The private key is usually not an X.509 certificate. You can find it as PFX or P12 files that you need to import in X509CertificateCollectionto get the private key as an instance X509Certificate.

( PFX P12) Windows, X509Store, X509Certificate.

PEM, . CERT/PEM PFX PFX.

0

Source: https://habr.com/ru/post/1647990/


All Articles