![]() |
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
(Tcl) Load PKCS12 / PFX and Access ContentsLoads a PKCS12 / PFX file and iterates over the contents which include private keys and certificates. Note: This example requires Chilkat v11.0.0 or greater.
load ./chilkat.dll set success 0 set pfx [new_CkPfx] # Load the PKCS12 from a file set success [CkPfx_LoadPfxFile $pfx "/someDir/my.p12" "pfxFilePassword"] if {$success == 0} then { puts [CkPfx_lastErrorText $pfx] delete_CkPfx $pfx exit } set numPrivateKeys [CkPfx_get_NumPrivateKeys $pfx] set privKey [new_CkPrivateKey] puts "Private Keys:" set i 0 while {$i < $numPrivateKeys} { CkPfx_PrivateKeyAt $pfx $i $privKey # Do something with the private key ... set i [expr $i + 1] } set cert [new_CkCert] set numCerts [CkPfx_get_NumCerts $pfx] puts "Certs:" set i 0 while {$i < $numCerts} { CkPfx_CertAt $pfx $i $cert 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 success [CkCert_GetPrivateKey $cert $privKey] # ... } set i [expr $i + 1] } delete_CkPfx $pfx delete_CkPrivateKey $privKey delete_CkCert $cert |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.