Node.js
Node.js
Find Certificate by Subject CN (Common Name)
See more Cert Store Examples
Demonstrates how to find a certificate having the specified subject CN.Note: Requires Chilkat v10.1.2 or later.
Chilkat Node.js Downloads
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 CN = "Example ABC".
var json = new chilkat.JsonObject();
json.UpdateString("CN","Example ABC");
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();