Sample code for 30+ languages & platforms
Lua

Load Certificate from .cer and Private Key from .pem

See more Certificates Examples

Load a certificate from a .cer and its associated private key from a .pem.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

local cert = chilkat.Cert.new()
local success = cert:load_from_file("C:/certs_and_keys/Certificate.cer")
if not success then
    print(cert.last_error_text)
    return
end

local sbPem = chilkat.StringBuilder.new()
success = sbPem:load_file("C:/certs_and_keys/PrivateKey.pem", "utf-8")
if not success then
    print("Failed to load private key PEM")
    return
end

success = cert:set_private_key_pem(sbPem:get_as_string())
if not success then
    print(cert.last_error_text)
    return
end

print("The certificate and associated private key are now loaded and ready for signing.")