Sample code for 30+ languages & platforms
PHP Extension

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

PHP Extension
<?php

include("chilkat.php");

$success = false;

$cert = new CkCert();

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

$pubkey = new CkPublicKey();
$cert->GetPublicKey($pubkey);

// Examine the public key as XML..
print $pubkey->getXml() . "\n";

?>