|  | 
Chilkat  HOME  Android™  AutoIt  C  C#  C++  Chilkat2-Python  CkPython  Classic ASP  DataFlex  Delphi DLL  Go  Java  Node.js  Objective-C  PHP Extension  Perl  PowerBuilder  PowerShell  PureBasic  Ruby  SQL Server  Swift  Tcl  Unicode C  Unicode C++  VB.NET  VBScript  Visual Basic 6.0  Visual FoxPro  Xojo Plugin
| (Unicode C) Open Smartcard Certificate Store (or from USB Token)Demonstrates how to open the certificate store of the smart card currently in the reader (or the USB token). Iterates over the certs found on the smartcard. Note: This example requires Chilkat v10.1.2 or greater. 
 #include <C_CkCertStoreW.h> #include <C_CkCertW.h> void ChilkatSample(void) { HCkCertStoreW certStore; BOOL success; HCkCertW cert; int i; int numCerts; certStore = CkCertStoreW_Create(); // Access the certificates on the smart card or USB token via the Chilkat certificate store class. // Note: Always pass the empty string to OpenSmartcard. // --------------------------------------------------------------------------------------------------------- // The following is true only for Chilkat v10.1.1 and earlier: // Also, the Chilkat CertStore class can only use MS CNG or CryptoAPI. // Some smartcard/USB token drivers only support PKCS11 or ScMinidriver. // You may get better results using Chilkat.Cert.LoadFromSmartcard because // Cert.LoadFromSmartcard can automatically detect and utilize PKCS11, ScMinidriver, CNG, and CryptoAPI. // --------------------------------------------------------------------------------------------------------- // Starting in Chilkat versions after v10.1.1, OpenSmartcard also works with // Apple Keychain and PKCS11 drivers on Windows, Linux, and MacOS. // --------------------------------------------------------------------------------------------------------- success = CkCertStoreW_OpenSmartcard(certStore,L""); if (success == FALSE) { wprintf(L"%s\n",CkCertStoreW_lastErrorText(certStore)); CkCertStoreW_Dispose(certStore); return; } wprintf(L"%s\n",CkCertStoreW_lastErrorText(certStore)); // Iterate over certificates on the smartcard. cert = CkCertW_Create(); i = 0; numCerts = CkCertStoreW_getNumCertificates(certStore); wprintf(L"numCerts = %d\n",numCerts); while ((i < numCerts)) { CkCertStoreW_GetCert(certStore,i,cert); wprintf(L"%s\n",CkCertW_subjectCN(cert)); wprintf(L"%s\n",CkCertW_serialNumber(cert)); if (CkCertW_IsRsa(cert) == TRUE) { wprintf(L"key type is RSA\n"); } if (CkCertW_IsEcdsa(cert) == TRUE) { wprintf(L"key type is ECDSA\n"); } wprintf(L"has private key: %d\n",CkCertW_HasPrivateKey(cert)); wprintf(L"----\n"); i = i + 1; } CkCertStoreW_Dispose(certStore); CkCertW_Dispose(cert); } | ||||||
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.