Bla*_*Spy 10 c# ssl https x509certificate .net-core
我使用OpenSSL创建了X509证书.我试图在.NET Core 2.0中的X509Certificate2类上使用Import方法加载它.
var cert = new X509Certificate2();
cert.Import(_path);
Run Code Online (Sandbox Code Playgroud)
但是抛出以下异常:
System.PlatformNotSupportedException : X509Certificate is immutable on this
platform. Use the equivalent constructor instead.
Run Code Online (Sandbox Code Playgroud)
我应该使用哪种构造函数/从磁盘加载此证书的正确方法是什么?
Iva*_*uba 16
您可以使用
var x509 = new X509Certificate2(File.ReadAllBytes(_path));
Run Code Online (Sandbox Code Playgroud)