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

Iterate over Certificates in a Certificate Store

See more Cert Store Examples

Demonstrates how to iterate over the certificates in a certificate store.

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

local cert = chilkat.Cert.new()

local numCerts = certStore.num_certificates
local i = 0

while i < numCerts do
    -- Load the cert object with the Nth certificate.
    certStore:get_cert(i, cert)
    print(i .. ": " .. cert.subject_cn)
    i = i + 1
end