Sample code for 30+ languages & platforms
Perl 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 Perl Downloads

Perl
use strict;
use warnings;
use Chilkat2;

my $cert = Chilkat2::Cert->new;

my $success = $cert->LoadFromFile('qa_data/pem/my_cert.pem');
if (!$success) {
    print $cert->LastErrorText, "\n";
    exit;
}

my $pubkey = Chilkat2::PublicKey->new;
$cert->GetPublicKey($pubkey);

# Examine the public key as XML..
print $pubkey->GetXml(), "\n";