Sample code for 30+ languages & platforms
PHP Extension

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 PHP Extension Downloads

PHP Extension
<?php

include("chilkat.php");

$success = false;

$cert = new CkCert();

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

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

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

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

?>