[英]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: 当我尝试时,我在同一个目录中有一个certificate.cer文件(如果较新,则进行复制),但其中包含RSA密钥:
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. 您可以将文件名传递给new()方法。
Try: 尝试:
X509Certificate2 x509 = new X509Certificate2(certificateFile);
If the certificate has a password, you must also supply this (where password
is a String): 如果证书具有密码,则还必须提供此
password
(其中password
是字符串):
X509Certificate2 x509 = new X509Certificate2(certificateFile, password);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.