![]() |
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
(PureBasic) 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.
IncludeFile "CkCert.pb" IncludeFile "CkCertStore.pb" Procedure ChilkatExample() certStore.i = CkCertStore::ckCreate() If certStore.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; 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.i = CkCertStore::ckOpenSmartcard(certStore,"") If success = 0 Debug CkCertStore::ckLastErrorText(certStore) CkCertStore::ckDispose(certStore) ProcedureReturn EndIf Debug CkCertStore::ckLastErrorText(certStore) ; Iterate over certificates on the smartcard. i.i = 0 numCerts.i = CkCertStore::ckNumCertificates(certStore) Debug "numCerts = " + Str(numCerts) While (i < numCerts) cert.i = CkCertStore::ckGetCertificate(certStore,i) Debug CkCert::ckSubjectCN(cert) Debug CkCert::ckSerialNumber(cert) If CkCert::ckIsRsa(cert) = 1 Debug "key type is RSA" EndIf If CkCert::ckIsEcdsa(cert) = 1 Debug "key type is ECDSA" EndIf Debug "has private key: " + Str(CkCert::ckHasPrivateKey(cert)) Debug "----" CkCert::ckDispose(cert) i = i + 1 Wend CkCertStore::ckDispose(certStore) ProcedureReturn EndProcedure |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.