Sample code for 30+ languages & platforms
Unicode C++

Find a Certificate in the "Other People" Windows Certificate Store

See more Certificates Examples

Demonstrates how to open the "Current User --> Other People" Windows certificate store, and locates a certificate matching an email address.

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkCertStoreW.h>
#include <CkJsonObjectW.h>
#include <CkCertW.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkCertStoreW certStore;

    // The "AddressBook" is the "Other People" certificate store as shown in certmgr.msc
    bool readOnly = true;
    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());
    }