Sample code for 30+ languages & platforms
Unicode C

Windows Certificate Stores - Find Certificate by Common Name

See more Certificates Examples

Searches the Windows certificate stores for a certificate that matches the specified common name (CN).

Note: This example requires Chilkat v10.0.0 or greater.

Chilkat Unicode C Downloads

Unicode C
#include <C_CkCertW.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkCertW cert;

    success = FALSE;

    cert = CkCertW_Create();
    success = CkCertW_LoadByCommonName(cert,L"Chilkat Software, Inc.");
    if (success == FALSE) {
        wprintf(L"%s\n",CkCertW_lastErrorText(cert));
        CkCertW_Dispose(cert);
        return;
    }

    wprintf(L"%s\n",CkCertW_subjectDN(cert));
    wprintf(L"Success.\n");


    CkCertW_Dispose(cert);

    }