Sample code for 30+ languages & platforms
AutoIt

Find Certificate by SHA1 Thumbprint

See more Cert Store Examples

Demonstrates how to find a certificate having the specified hexadecimal SHA1 thumbprint.

Note: Requires Chilkat v10.1.2 or later.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

$oCertStore = ObjCreate("Chilkat.CertStore")

; This opens the Current User certificate store on Windows,
; On MacOS and iOS it opens the default Keychain.
Local $bReadOnly = False
$bSuccess = $oCertStore.OpenCurrentUserStore($bReadOnly)
If ($bSuccess = False) Then
    ConsoleWrite($oCertStore.LastErrorText & @CRLF)
    Exit
EndIf

; Find the certificate having a specific SHA1 thumbprint.
$oJson = ObjCreate("Chilkat.JsonObject")
Local $sHexThumbprint = "767192374BE3C1512D2CB80734926D40E96D6DC2"
$oJson.UpdateString("thumbprint",$sHexThumbprint)

$oCert = ObjCreate("Chilkat.Cert")
$bSuccess = $oCertStore.FindCert($oJson,$oCert)
If ($bSuccess = True) Then
    ; Show the full distinguished name of the certificate.
    ConsoleWrite("Found: " & $oCert.SubjectDN & @CRLF)
Else
    ConsoleWrite("Not found." & @CRLF)
EndIf