Sample code for 30+ languages & platforms
AutoIt

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

AutoIt
Local $bSuccess = False

$oCertStore = ObjCreate("Chilkat.CertStore")

; This example will search the certs on connected USB tokens and smartcards.
Local $sArgNotUsed = ""
$bSuccess = $oCertStore.OpenSmartcard($sArgNotUsed)
If ($bSuccess = False) Then
    ConsoleWrite($oCertStore.LastErrorText & @CRLF)
    Exit
EndIf

; Find the certificate having a serial number = "48FC93B46055948D36A7C98A89D69416".
Local $sHexSerial = "48FC93B46055948D36A7C98A89D69416"
$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.UpdateString("serial",$sHexSerial)

$oCert = ObjCreate("Chilkat.Cert")
$bSuccess = $oCertStore.FindCert($oJson,$oCert)
If ($bSuccess = True) Then
    ; Show the serial number and subject CN
    ConsoleWrite("Found: " & $oCert.SerialNumber & ", " & $oCert.SubjectCN & @CRLF)
Else
    ConsoleWrite("Not found." & @CRLF)
EndIf