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

Get Certificate's Public Key

Loads a certificate from PEM and gets the public key.

Chilkat Perl Downloads

Chilkat2 Perl
use strict;
use warnings;
use Chilkat2;

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

my $strPem = '-----BEGIN CERTIFICATE----- ...';

my $success = $cert->LoadPem($strPem);
if (!$success) {
    print $cert->LastErrorText, "\n";
    exit;
}

my $pubKey = Chilkat2::PublicKey->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";