Sample code for 30+ languages & platforms
Lianja

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 Lianja Downloads

Lianja
llSuccess = .F.

loCertStore = createobject("CkCertStore")

// This example will search the certs on connected USB tokens and smartcards.
lcArgNotUsed = ""
llSuccess = loCertStore.OpenSmartcard(lcArgNotUsed)
if (llSuccess = .F.) then
    ? loCertStore.LastErrorText
    release loCertStore
    return
endif

// Find the certificate having a serial number = "48FC93B46055948D36A7C98A89D69416".
lcHexSerial = "48FC93B46055948D36A7C98A89D69416"
loJson = createobject("CkJsonObject")
loJson.UpdateString("serial",lcHexSerial)

loCert = createobject("CkCert")
llSuccess = loCertStore.FindCert(loJson,loCert)
if (llSuccess = .T.) then
    // Show the serial number and subject CN
    ? "Found: " + loCert.SerialNumber + ", " + loCert.SubjectCN
else
    ? "Not found."
endif



release loCertStore
release loJson
release loCert