Sample code for 30+ languages & platforms
Ruby

Get Certificate's Public Key

Loads a certificate from PEM and gets the public key.

Chilkat Ruby Downloads

Ruby
require 'chilkat'

success = false

cert = Chilkat::CkCert.new()

strPem = "-----BEGIN CERTIFICATE----- ..."

success = cert.LoadPem(strPem)
if (success == false)
    print cert.lastErrorText() + "\n";
    exit
end

pubKey = Chilkat::CkPublicKey.new()
cert.GetPublicKey(pubKey)

# You can now use the public key object however it is needed,
# and access its various properties and methods..

print pubKey.getXml() + "\n";