C# x509 证书解码器

C# x509 certificate decoder

我正在寻找如何从字符串中解码 x509 证书的 C# 代码,如本页所示:https://www.sslshopper.com/certificate-decoder.html

我有一个以 MII... 开头并以 == 结尾的证书字符串。

当我在 https://www.sslshopper.com/certificate-decoder.html 中通过它时,它可以工作,但我想拥有自己的工具,如本网站。

有什么帮助吗?

I have a certificate string, that starts with MII... and ends with ==

它是 ASN.1 DER 编码证书的 Base64 格式。您可以将此字符串转换为字节数组,然后构造 X509Certificate2 class:

的实例
byte[] bytes = Convert.FromBase64String("MII<...>==");
var cert = new X509Certificate2(bytes);

进一步阅读:

Convert.FromBase64String Method (String)

X509Certificate2 Class