[英]How to read X509 Signing Certificate content from string in .net?
I have X509 Signing Certificate inside of a string like: 我在像这样的字符串中有X509签名证书:
var signingCertificate = -----BEGIN CERTIFICATE-----\r\nMIICTjCCAbegAw.........-----END CERTIFICATE-----
Now I want to read the content of this certificate. 现在,我想阅读此证书的内容。 i know we can do it using X509Certificate2 object but that reads from file directly.
我知道我们可以使用X509Certificate2对象来做到这一点,但这直接从文件中读取。 Is there anyway to read the content from string?
反正有从字符串中读取内容吗?
You can convert your string to byte array, and create a X509Certificate2 object from it. 您可以将字符串转换为字节数组,并从中创建一个X509Certificate2对象。
byte[] bytes = Encoding.ASCII.GetBytes(signingCertificate);
var x509Certificate2 = new X509Certificate2(bytes);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.