Lua Requires Chilkat v10.1.2+
Lua
Find Certificate by Subject O (Organization)
See more Cert Store Examples
Demonstrates how to find a certificate having the specified subject organization.Chilkat Lua Downloads
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 Subject O = "ICP-Brasil".
local json = chilkat.JsonObject.new()
local organization = "ICP-Brasil"
json:update_string("O", organization)
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