Sample code for 30+ languages & platforms
Lianja

Iterate over Certificates in a Certificate Store

See more Cert Store Examples

Demonstrates how to iterate over the certificates in a certificate store.

Note: Requires Chilkat v10.1.2 or later.

Chilkat Lianja Downloads

Lianja
llSuccess = .F.

loCertStore = createobject("CkCertStore")

// This opens the Current User certificate store on Windows,
// On MacOS and iOS it opens the default Keychain.
llReadOnly = .F.
llSuccess = loCertStore.OpenCurrentUserStore(llReadOnly)
if (llSuccess = .F.) then
    ? loCertStore.LastErrorText
    release loCertStore
    return
endif

loCert = createobject("CkCert")

lnNumCerts = loCertStore.NumCertificates
i = 0

do while (i < lnNumCerts)
    // Load the cert object with the Nth certificate.
    loCertStore.GetCert(i,loCert)
    ? str(i) + ": " + loCert.SubjectCN
    i = i + 1
enddo


release loCertStore
release loCert