private static IStorePal PfxToCollection(OpenSslPkcs12Reader pfx, string password) { pfx.Decrypt(password); X509Certificate2Collection coll = new X509Certificate2Collection(); foreach (OpenSslX509CertificateReader certPal in pfx.ReadCertificates()) { coll.Add(new X509Certificate2(certPal)); } return(new OpenSslX509StoreProvider(coll)); }
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); }
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; }
private static IStorePal PfxToCollection(OpenSslPkcs12Reader pfx, string password) { pfx.Decrypt(password); X509Certificate2Collection coll = new X509Certificate2Collection(); foreach (OpenSslX509CertificateReader certPal in pfx.ReadCertificates()) { coll.Add(new X509Certificate2(certPal)); } return new OpenSslX509StoreProvider(coll); }