(Tcl) Load PFX (PKCS#12) and List Certificates
Loads a PFX file (.pfx, .p12) and iterates over the certificates found within.
load ./chilkat.dll
set certStore [new_CkCertStore]
set pfxPath "/Users/chilkat/testData/pfx/chilkat_ssl.pfx"
set pfxPassword "test"
set success [CkCertStore_LoadPfxFile $certStore $pfxPath $pfxPassword]
if {$success != 1} then {
puts [CkCertStore_lastErrorText $certStore]
delete_CkCertStore $certStore
exit
}
set numCerts [CkCertStore_get_NumCertificates $certStore]
puts "PFX contains $numCerts certificates"
set i 0
while {$i < $numCerts} {
# cert is a CkCert
set cert [CkCertStore_GetCertificate $certStore $i]
puts "$i: (Common Name) [CkCert_subjectCN $cert]"
puts "$i: (Serial Number) [CkCert_serialNumber $cert]"
puts "$i: (Distinguished Name) [CkCert_subjectDN $cert]"
delete_CkCert $cert
set i [expr $i + 1]
}
delete_CkCertStore $certStore
|