从磁盘 .Net Core 加载 X509 证书
Load X509 certificate from disk .Net Core
我使用 OpenSSL 创建了一个 X509 证书。我正在尝试在 .NET Core 2.0 中使用 X509Certificate2 class 上的 Import 方法加载它。
var cert = new X509Certificate2();
cert.Import(_path);
但是抛出如下异常:
System.PlatformNotSupportedException : X509Certificate is immutable on this
platform. Use the equivalent constructor instead.
我应该使用哪个构造函数/从磁盘加载此证书的正确方法是什么?
您可以使用
var x509 = new X509Certificate2(File.ReadAllBytes(_path));
我使用 OpenSSL 创建了一个 X509 证书。我正在尝试在 .NET Core 2.0 中使用 X509Certificate2 class 上的 Import 方法加载它。
var cert = new X509Certificate2();
cert.Import(_path);
但是抛出如下异常:
System.PlatformNotSupportedException : X509Certificate is immutable on this
platform. Use the equivalent constructor instead.
我应该使用哪个构造函数/从磁盘加载此证书的正确方法是什么?
您可以使用
var x509 = new X509Certificate2(File.ReadAllBytes(_path));