Tcl
Tcl
Load P7B and List Certificates
Demonstrates how to load a .p7b containing certificates and accesses each individual certificate.Chilkat Tcl Downloads
load ./chilkat.dll
set success 0
# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
set success 0
set pem [new_CkPem]
# Load the .p7b from a file.
set success [CkPem_LoadP7bFile $pem "/Users/chilkat/testData/p7b/myCerts.p7b"]
if {$success != 1} then {
puts [CkPem_lastErrorText $pem]
delete_CkPem $pem
exit
}
set numCerts [CkPem_get_NumCerts $pem]
if {$numCerts == 0} then {
puts "Error: Expected the .p7b to contain certificates."
delete_CkPem $pem
exit
}
# Access each certificate and show the DN (Distinguished Name)
for {set i 1} {$i <= $numCerts} {incr i} {
# cert is a CkCert
set cert [CkPem_GetCert $pem [expr $i - 1]]
puts "$i: [CkCert_subjectDN $cert]"
delete_CkCert $cert
}
delete_CkPem $pem