【问题标题】:X509 Cannot find requested objectX509 找不到请求的对象
【发布时间】:2013-03-20 14:50:23
【问题描述】:

当我尝试使用 RSA 密钥时,我在同一目录中有一个 certificate.cer 文件(如果更新,则复制):

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

我也一样

“找不到请求的对象”

错误。怎么才能不报错?

【问题讨论】:

  • 设置后检查certificateFile的值会得到什么?

标签: c# x509certificate x509


【解决方案1】:

您可以将文件名传递给 new() 方法。

试试:

X509Certificate2 x509 = new X509Certificate2(certificateFile);

如果证书有密码,您还必须提供密码(其中password 是字符串):

X509Certificate2 x509 = new X509Certificate2(certificateFile, password);

【讨论】:

  • 如果你有一个变量而不是文件中的字节,你怎么能解析证书?
猜你喜欢
  • 2021-07-08
  • 1970-01-01
  • 1970-01-01
  • 2021-08-28
  • 2016-11-18
  • 2016-04-10
  • 2011-07-01
  • 1970-01-01
  • 2012-02-26
相关资源
最近更新 更多