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

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 Downloads

PHP
<?php

use Chilkat2\Cert;
use Chilkat2\PublicKey;

$cert = new Cert();

try {
    $cert->LoadFromFile('qa_data/pem/my_cert.pem');
} catch (\Chilkat2\Exception $e) {
    echo $e->getMessage(), "\n";
    exit;
}

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

// Examine the public key as XML..
echo $pubkey->GetXml(), "\n";