从磁盘.NET核心加载X509证书



我已经使用openssl创建了X509证书。我正在尝试使用x509certificate2类上的导入方法加载它,以.net core 2.0。

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

最新更新