Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

X509 Cannot find requested object

I have a certificate.cer file in the same directory (copy if newer) with the RSA key inside yet when I try:

string certificateFile = Environment.CurrentDirectory + "\\Certificate.cer";
X509Certificate2 x509 = new X509Certificate2(X509Certificate.CreateFromCertFile(certificateFile));

I get the same

"Cannot find requested object"

error. How can I not get the error?

like image 722
user2191209 Avatar asked Mar 20 '13 14:03

user2191209


1 Answers

You can just pass the filename into the new() method.

Try:

X509Certificate2 x509 = new X509Certificate2(certificateFile);

If the certificate has a password, you must also supply this (where password is a String):

X509Certificate2 x509 = new X509Certificate2(certificateFile, password);
like image 168
aaroncatlin Avatar answered Oct 27 '22 08:10

aaroncatlin