(Tcl) Iterate over Certificates in a Certificate Store
Demonstrates how to iterate over the certificates in a certificate store.
Note: Requires Chilkat v10.1.2 or later.
load ./chilkat.dll
set certStore [new_CkCertStore]
# This opens the Current User certificate store on Windows,
# On MacOS and iOS it opens the default Keychain.
set readOnly 0
set success [CkCertStore_OpenCurrentUserStore $certStore $readOnly]
if {$success == 0} then {
puts [CkCertStore_lastErrorText $certStore]
delete_CkCertStore $certStore
exit
}
set cert [new_CkCert]
set numCerts [CkCertStore_get_NumCertificates $certStore]
set i 0
while {$i < $numCerts} {
# Load the cert object with the Nth certificate.
CkCertStore_GetCert $certStore $i $cert
puts "$i: [CkCert_subjectCN $cert]"
set i [expr $i + 1]
}
delete_CkCertStore $certStore
delete_CkCert $cert
|