Sample code for 30+ languages & platforms
Lianja

Apple Keychain - List Certificates

See more Apple Keychain Examples

Iterates over the certificates in the Apple Keychain.

Chilkat Lianja Downloads

Lianja
llSuccess = .F.

loCertStore = createobject("CkCertStore")

// On MacOS and iOS, the OpenCurrentUserStore method opens the Keychain.
// The argument passed to OpenCurrentUserStore is ignored.
llSuccess = loCertStore.OpenCurrentUserStore(.F.)
if (llSuccess = .F.) then
    ? loCertStore.LastErrorText
    release loCertStore
    return
endif

lnNumCerts = loCertStore.NumCertificates
? "numCerts = " + str(lnNumCerts)

loCert = createobject("CkCert")
i = 0
do while i < lnNumCerts
    loCertStore.GetCert(i,loCert)
    ? loCert.SubjectDN
    ? loCert.SubjectCN
    ? loCert.SerialNumber
    ? "----"
    i = i + 1
enddo

loCertStore.CloseCertStore()


release loCertStore
release loCert