Lua Requires Chilkat v10.0.0+
Lua
Apple Keychain - Import Pfx
See more Apple Keychain Examples
Imports the certficates and private keys contained in .pfx (or .p12) to the Apple Keychain. If intermediate CA certs are contained in the PFX, they are also added to the Keychain if needed.Chilkat Lua Downloads
local chilkat = require("chilkat")
local pfxPath = "/Users/chilkat/qa_data/pfx/EXAMPLE.pfx"
local pfxPassword = "PASSWORD"
-- Load the PFX file.
local cert = chilkat.Cert.new()
local success = cert:load_pfx_file(pfxPath, pfxPassword)
if not success then
print(cert.last_error_text)
return
end
local certStore = chilkat.CertStore.new()
-- Note: On MacOS and iOS, the AddCertificate method adds to the Keychain.
-- There is no need to "open" the Keychain beforehand.
success = certStore:add_certificate(cert)
if not success then
print(certStore.last_error_text)
return
end
print("Success.")