加载X509Certificate结果异常CryptographicException"找不到原始签名者"

MrC*_*nky 16 c# x509certificate

我试图实例化一个X509Certificate对象,但我一直在运行相同CryptographicException的错误消息:

"找不到原始签名者".

我尝试了几种加载证书的方法:

// some different things that I have tried
var cert = X509Certificate.CreateFromCertFile(certFileName);
var cert2 = new X509Certificate(byteArray);
var cert3 = new X509Certificate(byteArray, secretString);
var cert4 = X509Certificate.CreateFromSignedFile(certFileName);
Run Code Online (Sandbox Code Playgroud)

我已尝试从文件和字节数组加载.每次我得到同样的错误.可能是什么导致了这个?

MrC*_*nky 16

我解决了这个问题.我试图只加载证书文件,该文件不包含私钥.要解决此问题,我必须在购买证书的计算机上安装私钥,然后将其导出为.pfx文件并将其移至我实际想要使用它的位置.我确定是一个新手的错误.希望我的愚蠢问题将有助于未来的其他新手.