【发布时间】:2018-05-25 20:52:40
【问题描述】:
从字节数组创建 X509Certificate2 实例在 Windows 上有效,但在 Linux 上失败并出现“CryptographicException”。
static void Main(string[] args)
{
var cert = new X509Certificate2(Cert.CertBytes);
}
在 Windows 上:创建了有效的 X509Certificate2 实例 在 Linux 上:抛出异常:
{System.Security.Cryptography.CryptographicException: Cannot find the
original signer.
at Internal.Cryptography.Pal.PkcsFormatReader.TryReadPkcs7(SafePkcs7Handle pkcs7, Boolean single, ICertificatePal& certPal, List`1& certPals)
at Internal.Cryptography.Pal.PkcsFormatReader.TryReadPkcs7Der(Byte[] rawData, Boolean single, ICertificatePal& certPal, List`1& certPals)
at Internal.Cryptography.Pal.CertificatePal.FromBlob(Byte[] rawData, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)
at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(Byte[] data)
at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData)
at CertTest.Program.Main(String[] args) in /home/CertTest/Program.cs:line 14}
我做错了吗?我假设一个证书就是一个证书,不管它是在哪个操作系统上解析的。
您可以在此处找到可以在 Windows 上解析但不能在 Linux 上解析的有效 X509 证书:https://gist.github.com/secana/9c13f8fa495681f8a30adb5d8754450e
我尝试了多个证书,但没有一个可以在 Linux 上运行。我没有 Mac,所以我无法测试它是否可以在那里工作。
使用 .Net Core 2.0.2 测试 在 Ubuntu 16.04、Ubuntu 17.10、OpenSuse Tumbleweed、Windows 10 上
【问题讨论】:
标签: c# linux .net-core x509certificate2 .net-standard