c# - 加载 X509Certificate 导致异常 CryptographicException "Cannot find the original signer"

标签 c# x509certificate

我正在尝试实例化一个 X509Certificate 对象,但我一直遇到相同的 CryptographicException,并显示错误消息:

"Cannot find the original signer".

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

// 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);

我试过从文件和字节数组加载。每次我得到同样的错误。可能是什么原因造成的?

最佳答案

我发现了问题。我试图只加载不包含私钥的证书文件。为了解决这个问题,我不得不在购买证书的机器上安装私钥,然后 export it as a .pfx file并将它移动到我真正想要使用它的地方。我确定这是一个新手错误。希望我的愚蠢问题将来能帮助其他新手。

关于c# - 加载 X509Certificate 导致异常 CryptographicException "Cannot find the original signer",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19190404/

相关文章:

c# - HttpWebRequest 序列

c# - IP 地址与机器名

c# - IIS下如何填充系统证书?

java - "java.security.cert.CertificateException: No name matching localhost found"无法在 Ubuntu 16.04 LTS 上解析

java - 如何将证书文件添加/转换为 pkcs12 文件

c# - 使用 LINQ 删除重复项会返回 "Error removing duplicates: Unable to cast object of type ' System.Int3 2' to type ' System.String'。”

c# - Vue 组件不呈现...呈现为空 HTML 注释

c# - 在代码隐藏中使用 "*"设置 Silverlight 网格列宽?

java.io.IOException : Short read of DER length

linux - 安装自签名证书 Linux yocto