【问题标题】:Client certificate issuer (thumbprint) in MVCMVC 中的客户端证书颁发者(指纹)
【发布时间】:2012-09-18 15:19:57
【问题描述】:

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

我知道如何从中获取 Request.ClientCertificateX509Certificate2,但我不知道如何检查颁发者。
Request.ClientCertificate.Issuer 给出了 Issuer 的主题,但我不认为足够安全。

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

【问题讨论】:

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


    【解决方案1】:
    // 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;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-16
      • 2014-09-04
      • 1970-01-01
      • 2023-03-30
      • 2021-04-13
      • 1970-01-01
      • 1970-01-01
      • 2013-11-04
      相关资源
      最近更新 更多