Sample code for 30+ languages & platforms
Chilkat2-Python

Apple Keychain - List Certificates

See more Apple Keychain Examples

Iterates over the certificates in the Apple Keychain.

Chilkat Chilkat2-Python Downloads

Chilkat2-Python
import sys
import chilkat2

success = False

certStore = chilkat2.CertStore()

# 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.NumCertificates
print("numCerts = " + str(numCerts))

cert = chilkat2.Cert()
i = 0
while i < numCerts :
    certStore.GetCert(i,cert)
    print(cert.SubjectDN)
    print(cert.SubjectCN)
    print(cert.SerialNumber)
    print("----")
    i = i + 1

certStore.CloseCertStore()