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
(PowerBuilder) 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.
integer li_rc oleobject loo_CertStore integer li_Success integer i integer li_NumCerts oleobject loo_Cert loo_CertStore = create oleobject // Use "Chilkat_9_5_0.CertStore" for versions of Chilkat < 10.0.0 li_rc = loo_CertStore.ConnectToNewObject("Chilkat.CertStore") if li_rc < 0 then destroy loo_CertStore MessageBox("Error","Connecting to COM object failed") return end if // 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. // --------------------------------------------------------------------------------------------------------- li_Success = loo_CertStore.OpenSmartcard("") if li_Success = 0 then Write-Debug loo_CertStore.LastErrorText destroy loo_CertStore return end if Write-Debug loo_CertStore.LastErrorText // Iterate over certificates on the smartcard. i = 0 li_NumCerts = loo_CertStore.NumCertificates Write-Debug "numCerts = " + string(li_NumCerts) do while (i < li_NumCerts) loo_Cert = loo_CertStore.GetCertificate(i) Write-Debug loo_Cert.SubjectCN Write-Debug loo_Cert.SerialNumber if loo_Cert.IsRsa() = 1 then Write-Debug "key type is RSA" end if if loo_Cert.IsEcdsa() = 1 then Write-Debug "key type is ECDSA" end if Write-Debug "has private key: " + string(loo_Cert.HasPrivateKey()) Write-Debug "----" destroy loo_Cert i = i + 1 loop destroy loo_CertStore |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.