Lua Requires Chilkat v10.1.2+
Lua
Load PFX/P12 File into Certificate Store Object
Demonstrates how to load a .pfx/.p12 into a certificate store object.Chilkat Lua Downloads
local chilkat = require("chilkat")
local certStore = chilkat.CertStore.new()
-- This only loads the contents of the PFX file into the certStore object.
-- It is not importing the PFX into the Windows certificate stores.
local pfxPassword = "badssl.com"
local success = certStore:load_pfx_file("qa_data/pfx/badssl.com-client.p12", pfxPassword)
if not success then
print(certStore.last_error_text)
return
end
-- Examine each certificate (loaded from the PFX) in this certStore object
local cert = chilkat.Cert.new()
local numCerts = certStore.num_certificates
local i = 0
while i < numCerts do
certStore:get_cert(i, cert)
print("hasPrivateKey=" .. tostring(cert:has_private_key()) .. ", " .. cert.subject_cn)
i = i + 1
end