Sample code for 30+ languages & platforms
Visual Basic 6.0

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 Visual Basic 6.0 Downloads

Visual Basic 6.0
Dim success As Long
success = 0

Dim certStore As New ChilkatCertStore

' This opens the Current User certificate store on Windows,
' On MacOS and iOS it opens the default Keychain.
Dim readOnly As Long
readOnly = 0
success = certStore.OpenCurrentUserStore(readOnly)
If (success = 0) Then
    Debug.Print certStore.LastErrorText
    Exit Sub
End If

Dim cert As New ChilkatCert

Dim numCerts As Long
numCerts = certStore.NumCertificates
Dim i As Long
i = 0

Do While (i < numCerts)
    ' Load the cert object with the Nth certificate.
    success = certStore.GetCert(i,cert)
    Debug.Print i & ": " & cert.SubjectCN
    i = i + 1
Loop