Sample code for 30+ languages & platforms
Node.js

Load PFX (PKCS#12) and List Certificates

See more Certificates Examples

Loads a PFX file (.pfx, .p12) and iterates over the certificates found within.

Chilkat Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

    var certStore = new chilkat.CertStore();

    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 chilkat.Cert();
    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;
    }


}

chilkatExample();