Lua
Lua
ZATCA Load Certificate and Private Key from PEM Files
See more ZATCA Examples
Demonstrates how to load a certificate and private key from a pair of PEM files.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- The LoadFromFile method will automatically detect the file format..
local cert = chilkat.Cert.new()
local success = cert:load_from_file("qa_data/zatca/cert.pem")
if not success then
print(cert.last_error_text)
return
end
print(cert.subject_cn)
-- Load the private key.
local privKey = chilkat.PrivateKey.new()
success = privKey:load_pem_file("qa_data/zatca/ec-secp256k1-priv-key.pem")
if not success then
print(privKey.last_error_text)
return
end
print("Key Type: " .. privKey.key_type)
-- Associate the private key with the certificate.
success = cert:set_private_key(privKey)
if not success then
print(cert.last_error_text)
return
end
print("Success.")