Xbase++
Xbase++
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 Xbase++ Downloads
LOCAL nSuccess
LOCAL oCertStore
LOCAL cArgNotUsed
LOCAL cHexSerial
LOCAL oJson
LOCAL oCert
nSuccess := 0
oCertStore := CreateObject("Chilkat.CertStore")
// This example will search the certs on connected USB tokens and smartcards.
cArgNotUsed := ""
nSuccess := oCertStore:OpenSmartcard(cArgNotUsed)
IF (nSuccess == 0)
? oCertStore:LastErrorText
oCertStore:destroy()
RETURN
ENDIF
// Find the certificate having a serial number = "48FC93B46055948D36A7C98A89D69416".
cHexSerial := "48FC93B46055948D36A7C98A89D69416"
oJson := CreateObject("Chilkat.JsonObject")
oJson:UpdateString("serial", cHexSerial)
oCert := CreateObject("Chilkat.Cert")
nSuccess := oCertStore:FindCert(oJson, oCert)
IF (nSuccess == 1)
// Show the serial number and subject CN
? "Found: " + oCert:SerialNumber + ", " + oCert:SubjectCN
ELSE
? "Not found."
ENDIF
oCertStore:destroy()
oJson:destroy()
oCert:destroy()