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

C
#include <C_CkCert.h>

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

    success = FALSE;

    cert = CkCert_Create();
    success = CkCert_LoadByCommonName(cert,"Chilkat Software, Inc.");
    if (success == FALSE) {
        printf("%s\n",CkCert_lastErrorText(cert));
        CkCert_Dispose(cert);
        return;
    }

    printf("%s\n",CkCert_subjectDN(cert));
    printf("Success.\n");


    CkCert_Dispose(cert);

    }