(JavaScript) Find Certificate by Subject O (Organization)
Demonstrates how to find a certificate having the specified subject organization.
Note: Requires Chilkat v10.1.2 or later.
var success = false;
var certStore = new CkCertStore();
// 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 CkJsonObject();
var organization = "ICP-Brasil";
json.UpdateString("O",organization);
var cert = new CkCert();
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.");
}
|