Sample code for 30+ languages & platforms
Lua Requires Chilkat v10.1.2+

Find Certificate by SHA1 Thumbprint

See more Cert Store Examples

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

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

local certStore = chilkat.CertStore.new()

-- This opens the Current User certificate store on Windows,
-- On MacOS and iOS it opens the default Keychain.
local readOnly = false
local success = certStore:open_current_user_store(readOnly)
if not success then
    print(certStore.last_error_text)
    return
end

-- Find the certificate having a specific SHA1 thumbprint.
local json = chilkat.JsonObject.new()
local hexThumbprint = "767192374BE3C1512D2CB80734926D40E96D6DC2"
json:update_string("thumbprint", hexThumbprint)

local cert = chilkat.Cert.new()
success = certStore:find_cert(json, cert)
if success then
    -- Show the full distinguished name of the certificate.
    print("Found: " .. cert.subject_dn)
else
    print("Not found.")
end