Sample code for 30+ languages & platforms
Tcl

Apple Keychain - List Certificates

See more Apple Keychain Examples

Iterates over the certificates in the Apple Keychain.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

set certStore [new_CkCertStore]

# On MacOS and iOS, the OpenCurrentUserStore method opens the Keychain.
# The argument passed to OpenCurrentUserStore is ignored.
set success [CkCertStore_OpenCurrentUserStore $certStore 0]
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} {
    CkCertStore_GetCert $certStore $i $cert
    puts [CkCert_subjectDN $cert]
    puts [CkCert_subjectCN $cert]
    puts [CkCert_serialNumber $cert]
    puts "----"
    set i [expr $i + 1]
}

CkCertStore_CloseCertStore $certStore

delete_CkCertStore $certStore
delete_CkCert $cert