(Unicode 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 <CkCertStoreW.h>
#include <CkJsonObjectW.h>
#include <CkCertW.h>
void ChilkatSample(void)
{
CkCertStoreW certStore;
// The "AddressBook" is the "Other People" certificate store as shown in certmgr.msc
bool readOnly = true;
bool success = certStore.OpenWindowsStore(L"CurrentUser",L"AddressBook",readOnly);
if (success != true) {
wprintf(L"%s\n",certStore.lastErrorText());
return;
}
// Find the certificate for the email address:
CkJsonObjectW jsonE;
jsonE.UpdateString(L"email",L"joe@example.com");
CkCertW cert;
success = certStore.FindCert(jsonE,cert);
if (success == false) {
wprintf(L"%s\n",certStore.lastErrorText());
return;
}
wprintf(L"Found certificate: %s\n",cert.subjectDN());
}
|