(Tcl) Apple Keychain - List Certs on Smartcards and USB Tokens
Iterates over the certificatse on connected smartcards and USB tokens via the Apple Keychain.
Note: This example requires Chilkat v10.0.0 or greater.
load ./chilkat.dll
set certStore [new_CkCertStore]
# On MacOS and iOS, the OpenSmartcard method opens the Keychain.
# The argument passed to OpenSmartcard is ignored.
set success [CkCertStore_OpenSmartcard $certStore ""]
if {$success == 0} then {
puts [CkCertStore_lastErrorText $certStore]
delete_CkCertStore $certStore
exit
}
set numCerts [CkCertStore_get_NumCertificates $certStore]
puts "numCerts = $numCerts"
set i 0
while {$i < $numCerts} {
# Note: Chilkat also gets the associated private key if it exists.
# You can simply use the cert in other places in Chilkat where a cert w/ private key is required.
# cert is a CkCert
set cert [CkCertStore_GetCertificate $certStore $i]
puts [CkCert_subjectDN $cert]
puts "has private key: [CkCert_HasPrivateKey $cert]"
delete_CkCert $cert
set i [expr $i + 1]
}
CkCertStore_CloseCertStore $certStore
delete_CkCertStore $certStore
|