Sample code for 30+ languages & platforms
Node.js

Find Certificate by Serial Number

See more Cert Store Examples

Demonstrates how to find a certificate having the specified hexadecimal serial number.

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 example will search the certs on connected USB tokens and smartcards.
    var argNotUsed = "";
    success = certStore.OpenSmartcard(argNotUsed);
    if (success == false) {
        console.log(certStore.LastErrorText);
        return;
    }

    // Find the certificate having a serial number = "48FC93B46055948D36A7C98A89D69416".
    var hexSerial = "48FC93B46055948D36A7C98A89D69416";
    var json = new chilkat.JsonObject();
    json.UpdateString("serial",hexSerial);

    var cert = new chilkat.Cert();
    success = certStore.FindCert(json,cert);
    if (success == true) {
        // Show the serial number and subject CN
        console.log("Found: " + cert.SerialNumber + ", " + cert.SubjectCN);
    }
    else {
        console.log("Not found.");
    }


}

chilkatExample();