Node.js
Node.js
Find Certificate by Email Address
Locate the certificate containing the specified email address in either the RFC822 Name or the Subject.Note: This example 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 = true;
success = certStore.OpenCurrentUserStore(readOnly);
if (success == false) {
console.log(certStore.LastErrorText);
return;
}
// Locate the certificate containing the specified email address in either the RFC822 Name or the Subject.
var json = new chilkat.JsonObject();
var email_address = "harold@example.com";
json.UpdateString("email",email_address);
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();