Chilkat2-Python
Chilkat2-Python
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 Chilkat2-Python Downloads
import sys
import chilkat2
success = False
certStore = chilkat2.CertStore()
# 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.NumCertificates
print("numCerts = " + str(numCerts))
cert = chilkat2.Cert()
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()