Sample code for 30+ languages & platforms
Lua Requires Chilkat v11.0.0+

Get Certificate Public Key from PEM

See more Certificates Examples

Demonstrates how to load a PEM file containing a certificate and access the public key.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

local cert = chilkat.Cert.new()

local success = cert:load_from_file("qa_data/pem/my_cert.pem")
if not success then
    print(cert.last_error_text)
    return
end

local pubkey = chilkat.PublicKey.new()
cert:get_public_key(pubkey)

-- Examine the public key as XML..
print(pubkey:get_xml())