Sample code for 30+ languages & platforms
Visual FoxPro

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 Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loCertStore
LOCAL lnReadOnly
LOCAL loJson
LOCAL lcHexThumbprint
LOCAL loCert

lnSuccess = 0

loCertStore = CreateObject('Chilkat.CertStore')

* This opens the Current User certificate store on Windows,
* On MacOS and iOS it opens the default Keychain.
lnReadOnly = 0
lnSuccess = loCertStore.OpenCurrentUserStore(lnReadOnly)
IF (lnSuccess = 0) THEN
    ? loCertStore.LastErrorText
    RELEASE loCertStore
    CANCEL
ENDIF

* Find the certificate having a specific SHA1 thumbprint.
loJson = CreateObject('Chilkat.JsonObject')
lcHexThumbprint = "767192374BE3C1512D2CB80734926D40E96D6DC2"
loJson.UpdateString("thumbprint",lcHexThumbprint)

loCert = CreateObject('Chilkat.Cert')
lnSuccess = loCertStore.FindCert(loJson,loCert)
IF (lnSuccess = 1) THEN
    * Show the full distinguished name of the certificate.
    ? "Found: " + loCert.SubjectDN
ELSE
    ? "Not found."
ENDIF

RELEASE loCertStore
RELEASE loJson
RELEASE loCert