(PureBasic) Iterate over Certificates in a Certificate Store
Demonstrates how to iterate over the certificates in a certificate store.
Note: Requires Chilkat v10.1.2 or later.
IncludeFile "CkCert.pb"
IncludeFile "CkCertStore.pb"
Procedure ChilkatExample()
certStore.i = CkCertStore::ckCreate()
If certStore.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; This opens the Current User certificate store on Windows,
; On MacOS and iOS it opens the default Keychain.
readOnly.i = 0
success.i = CkCertStore::ckOpenCurrentUserStore(certStore,readOnly)
If success = 0
Debug CkCertStore::ckLastErrorText(certStore)
CkCertStore::ckDispose(certStore)
ProcedureReturn
EndIf
cert.i = CkCert::ckCreate()
If cert.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
numCerts.i = CkCertStore::ckNumCertificates(certStore)
i.i = 0
While i < numCerts
; Load the cert object with the Nth certificate.
CkCertStore::ckGetCert(certStore,i,cert)
Debug Str(i) + ": " + CkCert::ckSubjectCN(cert)
i = i + 1
Wend
CkCertStore::ckDispose(certStore)
CkCert::ckDispose(cert)
ProcedureReturn
EndProcedure
|