(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 <CkCertStore.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;
}
CkCert *cert = 0;
cert = certStore.FindCertByRfc822Name("sales.edifact@somewhere.com");
if (certStore.get_LastMethodSuccess() != true) {
std::cout << certStore.lastErrorText() << "\r\n";
return;
}
std::cout << "Found certificate: " << cert->subjectDN() << "\r\n";
delete cert;
}
|