Sample code for 30+ languages & platforms
Visual Basic 6.0

Find Certificate by Serial Number

See more Cert Store Examples

Demonstrates how to find a certificate having the specified hexadecimal serial number.

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 example will search the certs on connected USB tokens and smartcards.
Dim argNotUsed As String
argNotUsed = ""
success = certStore.OpenSmartcard(argNotUsed)
If (success = 0) Then
    Debug.Print certStore.LastErrorText
    Exit Sub
End If

' Find the certificate having a serial number = "48FC93B46055948D36A7C98A89D69416".
Dim hexSerial As String
hexSerial = "48FC93B46055948D36A7C98A89D69416"
Dim json As New ChilkatJsonObject
success = json.UpdateString("serial",hexSerial)

Dim cert As New ChilkatCert
success = certStore.FindCert(json,cert)
If (success = 1) Then
    ' Show the serial number and subject CN
    Debug.Print "Found: " & cert.SerialNumber & ", " & cert.SubjectCN
Else
    Debug.Print "Not found."
End If