.net - MVC 中的客户端证书颁发者(指纹)

标签 .net asp.net-mvc-3 ssl-certificate

在 MVC 应用程序中,我需要验证客户端证书是否由特定 CA 签名/颁发。

我知道如何获取 Request.ClientCertificateX509Certificate2从中,但我无法弄清楚如何检查发行人。Request.ClientCertificate.Issuer给出了 Issuer 的主题,但我认为这不够安全。

我希望能够检查颁发者指纹,那么如何从客户端证书中检索它?

最佳答案

// get the X509 from HTTP client certificate
var x509 = new X509Certificate2(this.Request.ClientCertificate.Certificate);

// create the certificate chain by using the machine store
var chain = new X509Chain(true);
chain.ChainPolicy.RevocationMode = X509RevocationMode.Offline;
chain.Build(x509);

// at this point chain.ChainElements[0] will contain the original
// certificate, the higher indexes are the issuers.
// note that if the certificate is self-signed, there will be just one entry.
var issuer = chain.ChainElements[1].Certificate.Thumbprint;

关于.net - MVC 中的客户端证书颁发者(指纹),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12480015/

相关文章:

c# - 无法在 asp.net core 的 startup.cs 文件中找到 Use.RunTimePageInfo() 方法

ssl - 关于公钥,有些事情对我来说没有意义

ssl - 在服务器 TrustStore - Cielo 上安装 SSL?

java - 如何让自签名证书代码只执行一次?

JAVA服务器和.Net客户端编程

.net - F# 的 timeit 函数

c# - 如何在 Windows Store (Metro) 应用程序的 DataAnnotations 中使用 "ErrorMessageResourceType"

c# - 是什么导致: "The context cannot be used while the model is being created."?

asp.net-mvc - ASP.NET MVC 通过文件/文件路径确定 mime 类型

javascript - 在 IIS7 中托管 MVC3 项目时,为什么我的 AJAX 加载第一次失败?