(Unicode C) Load Certificate from Smartcard in Reader (or from USB Token)
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.)
#include <C_CkCertW.h>
void ChilkatSample(void)
{
HCkCertW cert;
BOOL success;
cert = CkCertW_Create();
// If you know the smart card PIN, set it prior to loading from the smartcard/USB token.
CkCertW_putSmartCardPin(cert,L"12345678");
// Pass an empty string to allow Chilkat to discover the smart card or USB token automatically.
success = CkCertW_LoadFromSmartcard(cert,L"");
if (success == FALSE) {
wprintf(L"%s\n",CkCertW_lastErrorText(cert));
CkCertW_Dispose(cert);
return;
}
wprintf(L"Cert loaded from smartcard: %s\n",CkCertW_subjectCN(cert));
CkCertW_Dispose(cert);
}
|