(C++) Find a Certificate in the "Other People" Windows Certificate Store
Demonstrates how to open the "Current User --> Other People" Windows certificate store, and locates a certificate matching an email address. Note: This example requires Chilkat v10.1.2 or greater.
#include <CkCertStore.h>
#include <CkJsonObject.h>
#include <CkCert.h>
void ChilkatSample(void)
{
CkCertStore certStore;
// The "AddressBook" is the "Other People" certificate store as shown in certmgr.msc
bool readOnly = true;
bool success = certStore.OpenWindowsStore("CurrentUser","AddressBook",readOnly);
if (success != true) {
std::cout << certStore.lastErrorText() << "\r\n";
return;
}
// Find the certificate for the email address:
CkJsonObject jsonE;
jsonE.UpdateString("email","joe@example.com");
CkCert cert;
success = certStore.FindCert(jsonE,cert);
if (success == false) {
std::cout << certStore.lastErrorText() << "\r\n";
return;
}
std::cout << "Found certificate: " << cert.subjectDN() << "\r\n";
}
|