Ejemplo n.º 1
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         ICertificatePal pal = Pal;
         Pal = null;
         if (pal != null)
         {
             pal.Dispose();
         }
     }
 }
Ejemplo n.º 2
0
        private static bool TryReadPkcs12(
            OpenSslPkcs12Reader pfx,
            string password,
            bool single,
            out ICertificatePal readPal,
            out List <ICertificatePal> readCerts)
        {
            pfx.Decrypt(password);

            ICertificatePal        first = null;
            List <ICertificatePal> certs = null;

            if (!single)
            {
                certs = new List <ICertificatePal>();
            }

            foreach (OpenSslX509CertificateReader certPal in pfx.ReadCertificates())
            {
                if (single)
                {
                    // When requesting an X509Certificate2 from a PFX only the first entry is
                    // returned.  Other entries should be disposed.

                    if (first == null)
                    {
                        first = certPal;
                    }
                    else if (certPal.HasPrivateKey && !first.HasPrivateKey)
                    {
                        first.Dispose();
                        first = certPal;
                    }
                    else
                    {
                        certPal.Dispose();
                    }
                }
                else
                {
                    certs.Add(certPal);
                }
            }

            readPal   = first;
            readCerts = certs;
            return(true);
        }
Ejemplo n.º 3
0
        public virtual void Reset()
        {
            _lazyCertHash               = null;
            _lazyIssuer                 = null;
            _lazySubject                = null;
            _lazySerialNumber           = null;
            _lazyKeyAlgorithm           = null;
            _lazyKeyAlgorithmParameters = null;
            _lazyPublicKey              = null;
            _lazyNotBefore              = DateTime.MinValue;
            _lazyNotAfter               = DateTime.MinValue;

            ICertificatePal pal = Pal;

            Pal = null;
            if (pal != null)
            {
                pal.Dispose();
            }
        }
Ejemplo n.º 4
0
 public void Dispose()
 {
     // If there's still a certificate, dispose it.
     _cert?.Dispose();
 }