Sample code for 30+ languages & platforms
Node.js

Find Certificate by Subject O (Organization)

See more Cert Store Examples

Demonstrates how to find a certificate having the specified subject organization.

Note: Requires Chilkat v10.1.2 or later.

Chilkat Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

    var certStore = new chilkat.CertStore();

    // This opens the Current User certificate store on Windows,
    // On MacOS and iOS it opens the default Keychain.
    var readOnly = false;
    success = certStore.OpenCurrentUserStore(readOnly);
    if (success == false) {
        console.log(certStore.LastErrorText);
        return;
    }

    // Find the certificate having a Subject O = "ICP-Brasil".
    var json = new chilkat.JsonObject();
    var organization = "ICP-Brasil";
    json.UpdateString("O",organization);

    var cert = new chilkat.Cert();
    success = certStore.FindCert(json,cert);
    if (success == true) {
        // Show the full distinguished name of the certificate.
        console.log("Found: " + cert.SubjectDN);
    }
    else {
        console.log("Not found.");
    }


}

chilkatExample();