Sample code for 30+ languages & platforms
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 C++ Downloads

C++
#include <CkCertStore.h>
#include <CkJsonObject.h>
#include <CkCert.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkCertStore certStore;

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