Sample code for 30+ languages & platforms
VB.NET

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 VB.NET Downloads

VB.NET
Dim success As Boolean = False

Dim certStore As New Chilkat.CertStore

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


Dim cert As New Chilkat.Cert

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

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