/// <summary> /// Create document /// </summary> /// <param name="crl"></param> /// <param name="certificateSerial"></param> /// <param name="issuerSerial"></param> /// <param name="defaultTtl"></param> /// <returns></returns> public static CrlDocument ToDocument(this Crl crl, string certificateSerial, string issuerSerial, TimeSpan?defaultTtl = null) { if (crl.ThisUpdate == DateTime.MinValue || crl.ThisUpdate == DateTime.MaxValue) { throw new ArgumentException(nameof(crl)); } var ttl = (defaultTtl ?? TimeSpan.FromMinutes(5)).TotalSeconds; if (crl.NextUpdate != null && crl.ThisUpdate < crl.NextUpdate) { ttl = (crl.ThisUpdate - crl.NextUpdate.Value).TotalSeconds; } return(new CrlDocument { CertificateSerialNumber = certificateSerial, SerialNumber = new SerialNumber(crl.SerialNumber).ToString(), IssuerSerialNumber = issuerSerial, ThisUpdate = crl.ThisUpdate, NextUpdate = crl.NextUpdate, Ttl = (int)ttl, RawData = crl.RawData }); }
/// <summary> /// Create crl /// </summary> /// <param name="crl"></param> public static X509CrlModel ToServiceModel(this Crl crl) { return(new X509CrlModel { Crl = crl.RawData, Issuer = crl.Issuer }); }
static void PingCrls(X509Certificate2 certificate) { var extractCrlDistributionPoints = CrlDistributionPointsExtractor.ExtractCrlDistributionPoints(certificate); Crl crl = FullCrlRevocationChecker.Instance.DownloadCrl(extractCrlDistributionPoints.CrlDistributionPoint); if (crl.IsValid) { PrintLine("Success"); } else { PrintLine("Invalid CRL retrieved"); } }
/// <summary> /// Checks that a full CRL can be retrieved and is valid. Expects that an environment has been set up. /// </summary> /// <returns><code>true</code> if the CRL is retrieved or else false</returns> public static bool VerifyFullCrl(OcesCertificate ocesCertificate) { Crl crl = CertificateRevocationHandler.RetrieveFullCrl(ocesCertificate); return(crl != null && crl.IsValid); }
/// <summary> /// Convert to bouncy castle crl /// </summary> /// <param name="crl"></param> /// <returns></returns> internal static X509Crl ToX509Crl(this Crl crl) { return(ToX509Crl(crl.RawData)); }