Lua Requires Chilkat v10.1.2+
Lua
Find Certificate by Subject OU (Organizational Unit)
See more Cert Store Examples
Demonstrates how to find a certificate having the specified subject organizational unit (OU).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 OU = "Secretaria da Receita Federal do Brasil - RFB".
local json = chilkat.JsonObject.new()
local ou = "Secretaria da Receita Federal do Brasil - RFB"
json:update_string("OU", ou)
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