示例#1
0
        /// <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
            });
        }
示例#2
0
 /// <summary>
 /// Create crl
 /// </summary>
 /// <param name="crl"></param>
 public static X509CrlModel ToServiceModel(this Crl crl)
 {
     return(new X509CrlModel {
         Crl = crl.RawData,
         Issuer = crl.Issuer
     });
 }
示例#3
0
        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");
            }
        }
示例#4
0
        /// <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);
        }
示例#5
0
 /// <summary>
 /// Convert to bouncy castle crl
 /// </summary>
 /// <param name="crl"></param>
 /// <returns></returns>
 internal static X509Crl ToX509Crl(this Crl crl)
 {
     return(ToX509Crl(crl.RawData));
 }