protected virtual void Dispose(bool disposing) { if (disposing) { ICertificatePal pal = Pal; Pal = null; if (pal != null) { pal.Dispose(); } } }
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); }
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(); } }
public void Dispose() { // If there's still a certificate, dispose it. _cert?.Dispose(); }