(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.
#include <CkCertStoreW.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;
}
CkCertW *cert = 0;
cert = certStore.FindCertByRfc822Name(L"sales.edifact@somewhere.com");
if (certStore.get_LastMethodSuccess() != true) {
wprintf(L"%s\n",certStore.lastErrorText());
return;
}
wprintf(L"Found certificate: %s\n",cert->subjectDN());
delete cert;
}
|