Sample code for 30+ languages & platforms
VB.NET

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

VB.NET
Dim success As Boolean = False

Dim certStore As New Chilkat.CertStore

' This example will search the certs on connected USB tokens and smartcards.
Dim argNotUsed As String = ""
success = certStore.OpenSmartcard(argNotUsed)
If (success = False) Then
    Debug.WriteLine(certStore.LastErrorText)
    Exit Sub
End If


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

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