【问题标题】:Load X509 certificate from disk .Net Core从磁盘 .Net Core 加载 X509 证书
【发布时间】:2018-05-25 04:25:08
【问题描述】:

我使用 OpenSSL 创建了 X509 证书。我正在尝试使用 .NET Core 2.0 中 X509Certificate2 类的 Import 方法加载它。

var cert = new X509Certificate2();
cert.Import(_path);

但是会抛出以下异常:

System.PlatformNotSupportedException : X509Certificate is immutable on this 
platform. Use the equivalent constructor instead.

我应该使用哪个构造函数/从磁盘加载此证书的正确方法是什么?

【问题讨论】:

标签: c# ssl https .net-core x509certificate


【解决方案1】:

你可以使用

var x509 = new X509Certificate2(File.ReadAllBytes(_path));

【讨论】:

  • @user1034912 很抱歉听到这个消息。您使用什么运行时版本? PFX 中是否包含私钥或它是临时的?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-12-30
  • 1970-01-01
  • 1970-01-01
  • 2017-07-28
  • 1970-01-01
  • 2022-12-17
  • 1970-01-01
相关资源
最近更新 更多