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

Get Certificate's Public Key

Loads a certificate from PEM and gets the public key.

Chilkat PHP Extension Downloads

PHP Extension
<?php

include("chilkat.php");

$success = false;

$cert = new CkCert();

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

$success = $cert->LoadPem($strPem);
if ($success == false) {
    print $cert->lastErrorText() . "\n";
    exit;
}

$pubKey = new CkPublicKey();
$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";

?>