How can I Get the details from Root-CA-Cert certificate (x509) chain using c#?

纵然是瞬间 提交于 2020-02-25 06:47:27

问题


Let's say I have three certificates (in Base64 format)

Root
 |
 --- CA
     |
     --- Cert (client/signing/whatever)

How can I Get the data from certificate chain in C#? (All those three certs may be in my computer cert store)

How can I Get the details from Root-CA-Cert certificate (x509) chain using c#?


回答1:


How can I Get the data from certificate chain in C#? 
...
How can I Get the details from Root-CA-Cert certificate (x509) chain using c#?

You can use .Net's X509Certificate Class. It has methods like GetCertHash, GetPublicKey, GetSerialNumber, GetEffectiveDateString (i.e., notBefore), GetExpirationDateString (i.e., notAfter); and properties like Issuer and Subject.

For the purposes of displaying information, there is no difference between a root certificate, intermediate certificate or server certificate. A CA is just self signed (some hand waiving), which means the Issuer and Subject are the same. You can also root your trust in an intermediate, and that would not be self signed. With intermediate and server certificates, the Issuer and Subject will likely be different.

Also, this is probably a better visualization:

Root or CA
 |
 --- Intermediate
     |
     --- Server (client/signing/whatever)


来源:https://stackoverflow.com/questions/24133323/how-can-i-get-the-details-from-root-ca-cert-certificate-x509-chain-using-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!