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
(Tcl) Load PKCS12 / PFX and Access ContentsLoads a PKCS12 / PFX file and iterates over the contents which include private keys and certificates.
load ./chilkat.dll set pfx [new_CkPfx] # Load the PKCS12 from a file set success [CkPfx_LoadPfxFile $pfx "/someDir/my.p12" "pfxFilePassword"] if {$success != 1} then { puts [CkPfx_lastErrorText $pfx] delete_CkPfx $pfx exit } set numPrivateKeys [CkPfx_get_NumPrivateKeys $pfx] # privKey is a CkPrivateKey puts "Private Keys:" set i 0 while {$i < $numPrivateKeys} { set privKey [CkPfx_GetPrivateKey $pfx $i] # Do something with the private key ... delete_CkPrivateKey $privKey set i [expr $i + 1] } # cert is a CkCert set numCerts [CkPfx_get_NumCerts $pfx] puts "Certs:" set i 0 while {$i < $numCerts} { set cert [CkPfx_GetCert $pfx $i] puts [CkCert_subjectDN $cert] # If the certificate has a private key (one of the private keys within the PFX) # then it can also be obtained via the certificate object: if {[CkCert_HasPrivateKey $cert] == 1} then { puts "Has private key!" set privKey [CkCert_ExportPrivateKey $cert] # ... delete_CkPrivateKey $privKey } delete_CkCert $cert set i [expr $i + 1] } delete_CkPfx $pfx |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.