8

我在同一目录中有一个 certificate.cer 文件(如果较新则复制),其中包含 RSA 密钥,但当我尝试时:

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

我也一样

“找不到请求的对象”

错误。我怎么不能得到错误?

4

1 回答 1

2

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

尝试:

X509Certificate2 x509 = new X509Certificate2(certificateFile);

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

X509Certificate2 x509 = new X509Certificate2(certificateFile, password);
于 2013-03-20T15:25:02.187 回答