Ejemplo n.º 1
0
        public ValidationResponse ValidateCertificate(X509Certificate2 certificate, String urlCRL)
        {
            try
            {
                byte[]  crl     = transferHttpDataService.GetFile(urlCRL);
                X509Crl x509crl = new X509CrlParser().ReadCrl(crl);
                Org.BouncyCastle.X509.X509Certificate certificateBC = Org.BouncyCastle.Security.DotNetUtilities.FromX509Certificate(certificate);
                X509CrlEntry crlEntry = x509crl.GetRevokedCertificate(certificateBC.SerialNumber);
                if (crlEntry != null)
                {
                    return(new ValidationResponse(CertificateStatus.REVOKED, crlEntry.RevocationDate));
                }

                return(new ValidationResponse(CertificateStatus.VALID));
            }
            catch (CommunicationException)
            {
                return(new ValidationResponse(CertificateStatus.UNKNOWN));
            }
        }