【发布时间】:2016-09-26 03:35:30
【问题描述】:
我有一个 ASP.net Web 应用程序,我的客户需要使用客户端 v3 证书对我的网站进行身份验证。
我需要检查的是: 1-证书有效 2- “发给 CN” 有特定的价值
我在 MVC 操作中执行以下操作:
var req = Request.ClientCertificate;
req 有一个名为IsValid 的属性,足以满足要求 (1)。现在,这里的问题是我无法检查 CN,因为我相信它存储在另一个名为 byte[0] 类型的属性中,称为 Certificate。
我尝试像这样阅读证书:
var x509 = new X509Certificate(req.Certificate);
但我有两个例外:
'x509.Issuer' threw an exception of type 'System.Security.Cryptography.CryptographicException'
'x509.Subject' threw an exception of type 'System.Security.Cryptography.CryptographicException'
如何阅读证书?
【问题讨论】:
标签: asp.net authentication ssl x509certificate