Sample code for 30+ languages & platforms
CkPython

Apple Keychain - List Certificates

See more Apple Keychain Examples

Iterates over the certificates in the Apple Keychain.

Chilkat CkPython Downloads

CkPython
import sys
import chilkat

success = False

certStore = chilkat.CkCertStore()

# On MacOS and iOS, the OpenCurrentUserStore method opens the Keychain.
# The argument passed to OpenCurrentUserStore is ignored.
success = certStore.OpenCurrentUserStore(False)
if (success == False):
    print(certStore.lastErrorText())
    sys.exit()

numCerts = certStore.get_NumCertificates()
print("numCerts = " + str(numCerts))

cert = chilkat.CkCert()
i = 0
while i < numCerts :
    certStore.GetCert(i,cert)
    print(cert.subjectDN())
    print(cert.subjectCN())
    print(cert.serialNumber())
    print("----")
    i = i + 1

certStore.CloseCertStore()