CkPython
CkPython
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 CkPython Downloads
import sys
import chilkat
success = False
certStore = chilkat.CkCertStore()
# On MacOS and iOS, the OpenSmartcard method opens the Keychain.
# The argument passed to OpenSmartcard is ignored.
success = certStore.OpenSmartcard("")
if (success == False):
print(certStore.lastErrorText())
sys.exit()
numCerts = certStore.get_NumCertificates()
print("numCerts = " + str(numCerts))
cert = chilkat.CkCert()
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.
certStore.GetCert(i,cert)
print(cert.subjectDN())
print(cert.subjectCN())
print(cert.serialNumber())
if (cert.IsRsa() == True):
print("key type is RSA")
if (cert.IsEcdsa() == True):
print("key type is ECDSA")
print("has private key: " + str(cert.HasPrivateKey()))
print("----")
i = i + 1
certStore.CloseCertStore()