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

Get Certificate's Public Key

Loads a certificate from PEM and gets the public key.

Chilkat PHP Downloads

Chilkat2 PHP
<?php

use Chilkat2\Cert;
use Chilkat2\PublicKey;

$cert = new Cert();

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

try {
    $cert->LoadPem($strPem);
} catch (\Chilkat2\Exception $e) {
    echo $e->getMessage(), "\n";
    exit;
}

$pubKey = new PublicKey();
$cert->GetPublicKey($pubKey);

// You can now use the public key object however it is needed,
// and access its various properties and methods..

echo $pubKey->GetXml(), "\n";