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?
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With