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

Get Public Key from Certificate PEM

See more Certificates Examples

Loads a certificate from a PEM file and gets the cert's public key.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

local cert = chilkat.Cert.new()

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

-- Get the certificate's public key:
local pubkey = chilkat.PublicKey.new()
cert:get_public_key(pubkey)

print(pubkey:get_pem(false))

-- OK.. we have the public key which can be used in other Chilkat classes/methods...