Sample code for 30+ languages & platforms
Perl

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 Perl Downloads

Perl
use chilkat();

$success = 0;

$cert = chilkat::CkCert->new();

$success = $cert->LoadFromFile("qa_data/certs/someCert.pem");
if ($success == 0) {
    print $cert->lastErrorText() . "\r\n";
    exit;
}

# Get the certificate's public key:
$pubkey = chilkat::CkPublicKey->new();
$cert->GetPublicKey($pubkey);

print $pubkey->getPem(0) . "\r\n";

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