Xbase++
Xbase++
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 Xbase++ Downloads
LOCAL nSuccess
LOCAL oCertStore
LOCAL nReadOnly
LOCAL oJson
LOCAL cHexThumbprint
LOCAL oCert
nSuccess := 0
oCertStore := CreateObject("Chilkat.CertStore")
// This opens the Current User certificate store on Windows,
// On MacOS and iOS it opens the default Keychain.
nReadOnly := 0
nSuccess := oCertStore:OpenCurrentUserStore(nReadOnly)
IF (nSuccess == 0)
? oCertStore:LastErrorText
oCertStore:destroy()
RETURN
ENDIF
// Find the certificate having a specific SHA1 thumbprint.
oJson := CreateObject("Chilkat.JsonObject")
cHexThumbprint := "767192374BE3C1512D2CB80734926D40E96D6DC2"
oJson:UpdateString("thumbprint", cHexThumbprint)
oCert := CreateObject("Chilkat.Cert")
nSuccess := oCertStore:FindCert(oJson, oCert)
IF (nSuccess == 1)
// Show the full distinguished name of the certificate.
? "Found: " + oCert:SubjectDN
ELSE
? "Not found."
ENDIF
oCertStore:destroy()
oJson:destroy()
oCert:destroy()