Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) ScMinidriver - Get CSP Container Map for Smart Card or USB TokenSee more ScMinidriver ExamplesReturns the contents of the CSP container map file (cmapfile). This gives an overview of what key containers and certificates exist in the smart card from a CSP's point of view.
integer li_rc oleobject loo_Scmd string ls_ReaderName integer li_Success oleobject loo_Json integer li_Index string ls_Guid integer li_Default integer li_SigKeySizeBits integer li_KexKeySizeBits string ls_KexCertSerialNum string ls_KexCertIssuerCN string ls_KexCertSubjectCN string ls_SigCertSerialNum string ls_SigCertIssuerCN string ls_SigCertSubjectCN integer i integer li_Count_i // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Scmd = create oleobject // Use "Chilkat_9_5_0.ScMinidriver" for versions of Chilkat < 10.0.0 li_rc = loo_Scmd.ConnectToNewObject("Chilkat.ScMinidriver") if li_rc < 0 then destroy loo_Scmd MessageBox("Error","Connecting to COM object failed") return end if // Reader names (smart card readers or USB tokens) can be discovered // via PCSC List Readers or PCSC Find Smart Cards ls_ReaderName = "SCM Microsystems Inc. SCR33x USB Smart Card Reader 0" li_Success = loo_Scmd.AcquireContext(ls_ReaderName) if li_Success = 0 then Write-Debug loo_Scmd.LastErrorText destroy loo_Scmd return end if loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") loo_Json.EmitCompact = 0 li_Success = loo_Scmd.GetCspContainerMap(loo_Json) if li_Success = 0 then Write-Debug loo_Scmd.LastErrorText destroy loo_Scmd destroy loo_Json return end if Write-Debug loo_Json.Emit() // Here is sample output: // See below for sample code to parse the JSON. // -------------------------------------------------------------- // Some notes: // // 1) Empty containers are not listed. // 2) The "index" is the index of the key container on the card. // Note that in the example output below, the card has 4 occupied containers // at indexes 0, 1, 2, and 5. // 3) If you see a key size (in bits) equal to 0, it means that key does not exist. // 4) A container can potentially contain 2 keys + certificates -- a key for signing (also known as // the "signature" key), and a key for authentication/authorization (also known as the // "key exchange" key). // 5) It is possible for a key to exist without the certificate. For example, in the results // below there is a 2048-bit key-exchange key at index 1, but no certificate. // 6) A certificate belonging to the key-exchange key is contained in the "kexCert" JSON member, // a certificate belonging to the signature key is contained in the "sigCert" JSON member (not shown below). // -------------------------------------------------------------- // { // "containers": [ // { // "index": 0, // "guid": "CertReq-PIVKeyC910-205fc3c2-19fe--42448", // "default": true, // "sigKeySizeBits": 0, // "kexKeySizeBits": 2048, // "kexCert": { // "serialNum": "15FBFBCF00010000313D", // "issuerCN": "PIVKey Device Certificate Authority", // "subjectCN": "PIVKey Device Certificate Authority" // } // }, // { // "index": 1, // "guid": "{7b3c32dd-e992-c58f-0822-67d72fd52d43}", // "default": false, // "sigKeySizeBits": 0, // "kexKeySizeBits": 2048 // }, // { // "index": 2, // "guid": "{57547a77-18e7-7516-f5da-6aee13b46bbc}", // "default": false, // "sigKeySizeBits": 0, // "kexKeySizeBits": 2048 // }, // { // "index": 5, // "guid": "{306fd6da-9954-4f75-95c0-178f607a41fb}", // "default": false, // "sigKeySizeBits": 0, // "kexKeySizeBits": 2048, // "kexCert": { // "serialNum": "17C1B793A24D1A81490F5F768E6D23A5", // "issuerCN": "Matt", // "subjectCN": "Matt" // } // } // ] // } // Use this online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON i = 0 li_Count_i = loo_Json.SizeOfArray("containers") do while i < li_Count_i loo_Json.I = i li_Index = loo_Json.IntOf("containers[i].index") ls_Guid = loo_Json.StringOf("containers[i].guid") li_Default = loo_Json.BoolOf("containers[i].default") li_SigKeySizeBits = loo_Json.IntOf("containers[i].sigKeySizeBits") li_KexKeySizeBits = loo_Json.IntOf("containers[i].kexKeySizeBits") ls_KexCertSerialNum = loo_Json.StringOf("containers[i].kexCert.serialNum") ls_KexCertIssuerCN = loo_Json.StringOf("containers[i].kexCert.issuerCN") ls_KexCertSubjectCN = loo_Json.StringOf("containers[i].kexCert.subjectCN") ls_SigCertSerialNum = loo_Json.StringOf("containers[i].sigCert.serialNum") ls_SigCertIssuerCN = loo_Json.StringOf("containers[i].sigCert.issuerCN") ls_SigCertSubjectCN = loo_Json.StringOf("containers[i].sigCert.subjectCN") i = i + 1 loop // Delete the context when finished with the card. li_Success = loo_Scmd.DeleteContext() if li_Success = 0 then Write-Debug loo_Scmd.LastErrorText end if destroy loo_Scmd destroy loo_Json |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.