(Tcl) Load PFX/P12 File into Certificate Store Object
Demonstrates how to load a .pfx/.p12 into a certificate store object.
load ./chilkat.dll
set certStore [new_CkCertStore]
# This only loads the contents of the PFX file into the certStore object.
# It is not importing the PFX into the Windows certificate stores.
set pfxPassword "badssl.com"
set success [CkCertStore_LoadPfxFile $certStore "qa_data/pfx/badssl.com-client.p12" $pfxPassword]
if {$success == 0} then {
puts [CkCertStore_lastErrorText $certStore]
delete_CkCertStore $certStore
exit
}
# Examine each certificate (loaded from the PFX) in this certStore object
set numCerts [CkCertStore_get_NumCertificates $certStore]
set i 0
while {$i < $numCerts} {
# cert is a CkCert
set cert [CkCertStore_GetCertificate $certStore $i]
puts "hasPrivateKey=[CkCert_HasPrivateKey $cert], [CkCert_subjectCN $cert]"
delete_CkCert $cert
set i [expr $i + 1]
}
delete_CkCertStore $certStore
|