(PureBasic) Apple Keychain - List Certificates
Iterates over the certificates in the Apple Keychain.Note: This example requires Chilkat v10.1.2 or greater.
IncludeFile "CkCert.pb"
IncludeFile "CkCertStore.pb"
Procedure ChilkatExample()
certStore.i = CkCertStore::ckCreate()
If certStore.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; On MacOS and iOS, the OpenCurrentUserStore method opens the Keychain.
; The argument passed to OpenCurrentUserStore is ignored.
success.i = CkCertStore::ckOpenCurrentUserStore(certStore,0)
If success = 0
Debug CkCertStore::ckLastErrorText(certStore)
CkCertStore::ckDispose(certStore)
ProcedureReturn
EndIf
numCerts.i = CkCertStore::ckNumCertificates(certStore)
Debug "numCerts = " + Str(numCerts)
cert.i = CkCert::ckCreate()
If cert.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
i.i = 0
While i < numCerts
CkCertStore::ckGetCert(certStore,i,cert)
Debug CkCert::ckSubjectDN(cert)
Debug CkCert::ckSubjectCN(cert)
Debug CkCert::ckSerialNumber(cert)
Debug "----"
i = i + 1
Wend
CkCertStore::ckCloseCertStore(certStore)
CkCertStore::ckDispose(certStore)
CkCert::ckDispose(cert)
ProcedureReturn
EndProcedure
|