(.NET Core C#) Load PFX (PKCS#12) and List Certificates
Loads a PFX file (.pfx, .p12) and iterates over the certificates found within.
Chilkat.CertStore certStore = new Chilkat.CertStore();
bool success;
string pfxPath = "/Users/chilkat/testData/pfx/chilkat_ssl.pfx";
string pfxPassword = "test";
success = certStore.LoadPfxFile(pfxPath,pfxPassword);
if (success != true) {
Debug.WriteLine(certStore.LastErrorText);
return;
}
int numCerts = certStore.NumCertificates;
Debug.WriteLine("PFX contains " + Convert.ToString(numCerts) + " certificates");
int i = 0;
while (i < numCerts) {
Chilkat.Cert cert = certStore.GetCertificate(i);
Debug.WriteLine(Convert.ToString(i) + ": (Common Name) " + cert.SubjectCN);
Debug.WriteLine(Convert.ToString(i) + ": (Serial Number) " + cert.SerialNumber);
Debug.WriteLine(Convert.ToString(i) + ": (Distinguished Name) " + cert.SubjectDN);
i = i + 1;
}
|