使用X509证书通过.cer文件对pdf数字签名时,得到错误No Private Key

时间:2018-08-06 19:06:10

标签: c# asp.net certificate x509certificate x509certificate2

我使用带有X509Certificate的.cer文件对pdf进行数字签名。但是在IExternalSignature上,我没有签名。错误出现“没有私钥”

这是我的代码

string uc= Server.MapPath("~/username.cer");
System.Security.Cryptography.X509Certificates.X509Certificate cert = new System.Security.Cryptography.X509Certificates.X509Certificate();
cert.Import(uc);
X509Certificate2 signatureCert = new X509Certificate2(cert);
IExternalSignature externalSignature = new X509Certificate2Signature(signatureCert, "SHA-1"); 

在最后一行,我收到错误消息“无私钥”

建议我解决方案

0 个答案:

没有答案