(JavaScript) Load PFX (PKCS#12) and List Certificates
Loads a PFX file (.pfx, .p12) and iterates over the certificates found within. Note: This example requires Chilkat v10.1.2 or greater.
var success = false;
var certStore = new CkCertStore();
var pfxPath = "/Users/chilkat/testData/pfx/chilkat_ssl.pfx";
var pfxPassword = "test";
success = certStore.LoadPfxFile(pfxPath,pfxPassword);
if (success !== true) {
console.log(certStore.LastErrorText);
return;
}
var numCerts = certStore.NumCertificates;
console.log("PFX contains " + numCerts + " certificates");
var cert = new CkCert();
var i = 0;
while (i < numCerts) {
certStore.GetCert(i,cert);
console.log(i + ": (Common Name) " + cert.SubjectCN);
console.log(i + ": (Serial Number) " + cert.SerialNumber);
console.log(i + ": (Distinguished Name) " + cert.SubjectDN);
i = i+1;
}
|