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

Load PFX/P12 File into Certificate Store Object

Demonstrates how to load a .pfx/.p12 into a certificate store object.

Chilkat Unicode C++ Downloads

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

void ChilkatSample(void)
    {
    bool success = false;

    CkCertStoreW certStore;

    //  This only loads the contents of the PFX file into the certStore object.
    //  It is not importing the PFX into the Windows certificate stores.
    const wchar_t *pfxPassword = L"badssl.com";
    success = certStore.LoadPfxFile(L"qa_data/pfx/badssl.com-client.p12",pfxPassword);
    if (success == false) {
        wprintf(L"%s\n",certStore.lastErrorText());
        return;
    }

    //  Examine each certificate (loaded from the PFX) in this certStore object
    CkCertW cert;
    int numCerts = certStore.get_NumCertificates();
    int i = 0;
    while (i < numCerts) {
        certStore.GetCert(i,cert);
        wprintf(L"hasPrivateKey=%d, %s\n",cert.HasPrivateKey(),cert.subjectCN());
        i = i + 1;
    }
    }