Sample code for 30+ languages & platforms
Node.js

Apple Keychain - List Certificates

See more Apple Keychain Examples

Iterates over the certificates in the Apple Keychain.

Chilkat Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

    var certStore = new chilkat.CertStore();

    // On MacOS and iOS, the OpenCurrentUserStore method opens the Keychain.
    // The argument passed to OpenCurrentUserStore is ignored.
    success = certStore.OpenCurrentUserStore(false);
    if (success == false) {
        console.log(certStore.LastErrorText);
        return;
    }

    var numCerts = certStore.NumCertificates;
    console.log("numCerts = " + numCerts);

    var cert = new chilkat.Cert();
    var i = 0;
    while (i < numCerts) {
        certStore.GetCert(i,cert);
        console.log(cert.SubjectDN);
        console.log(cert.SubjectCN);
        console.log(cert.SerialNumber);
        console.log("----");
        i = i+1;
    }

    certStore.CloseCertStore();

}

chilkatExample();