Lua Requires Chilkat v10.1.2+
Lua
Find Certificate by Serial Number
See more Cert Store Examples
Demonstrates how to find a certificate having the specified hexadecimal serial number.Chilkat Lua Downloads
local chilkat = require("chilkat")
local certStore = chilkat.CertStore.new()
-- This example will search the certs on connected USB tokens and smartcards.
local argNotUsed = ""
local success = certStore:open_smartcard(argNotUsed)
if not success then
print(certStore.last_error_text)
return
end
-- Find the certificate having a serial number = "48FC93B46055948D36A7C98A89D69416".
local hexSerial = "48FC93B46055948D36A7C98A89D69416"
local json = chilkat.JsonObject.new()
json:update_string("serial", hexSerial)
local cert = chilkat.Cert.new()
success = certStore:find_cert(json, cert)
if success then
-- Show the serial number and subject CN
print("Found: " .. cert.serial_number .. ", " .. cert.subject_cn)
else
print("Not found.")
end