Tcl
Tcl
Apple Keychain - List Certs on Smartcards and USB Tokens
See more Apple Keychain Examples
Iterates over the certificatse on connected smartcards and USB tokens via the Apple Keychain.Chilkat Tcl Downloads
load ./chilkat.dll
set success 0
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 cert [new_CkCert]
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.
CkCertStore_GetCert $certStore $i $cert
puts [CkCert_subjectDN $cert]
puts [CkCert_subjectCN $cert]
puts [CkCert_serialNumber $cert]
if {[CkCert_IsRsa $cert] == 1} then {
puts "key type is RSA"
}
if {[CkCert_IsEcdsa $cert] == 1} then {
puts "key type is ECDSA"
}
puts "has private key: [CkCert_HasPrivateKey $cert]"
puts "----"
set i [expr $i + 1]
}
CkCertStore_CloseCertStore $certStore
delete_CkCertStore $certStore
delete_CkCert $cert