Sample code for 30+ languages & platforms
C

Load Certificate from Smartcard in Reader (or from USB Token)

See more Certificates Examples

Demonstrates how to load the certificate that is on the smartcard currently inserted into the smartcard reader. (Also can load the smartcard on a USB token.)

Chilkat C Downloads

C
#include <C_CkCert.h>

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

    success = FALSE;

    cert = CkCert_Create();

    // If you know the smart card PIN, set it prior to loading from the smartcard/USB token.
    CkCert_putSmartCardPin(cert,"12345678");

    // Pass an empty string to allow Chilkat to discover the smart card or USB token automatically.
    success = CkCert_LoadFromSmartcard(cert,"");
    if (success == FALSE) {
        printf("%s\n",CkCert_lastErrorText(cert));
        CkCert_Dispose(cert);
        return;
    }

    printf("Cert loaded from smartcard: %s\n",CkCert_subjectCN(cert));


    CkCert_Dispose(cert);

    }