2012-09-18 5 views
3

MVC 응용 프로그램에서 클라이언트 인증서가 특정 CA에 의해 서명/발급되었는지 확인해야합니다.MVC의 클라이언트 인증서 발급자 (지문)

Request.ClientCertificate 및 X509Certificate2를 얻는 방법을 알고 있지만 발급자를 확인하는 방법을 알 수 없습니다. Request.ClientCertificate.Issuer는 Issuer의 주제를 제공하지만, 충분히 안전하다고는 생각하지 않습니다. 발급자 지문을 확인할 수 있기를 원하며 클라이언트 인증서에서 어떻게 검색합니까?

답변

2
// 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; 
관련 문제