Sample code for 30+ languages & platforms
PHP ActiveX

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 ActiveX Downloads

PHP ActiveX
<?php

$success = 0;

$cert = new COM("Chilkat.Cert");

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

// Get the certificate's public key:
$pubkey = new COM("Chilkat.PublicKey");
$cert->GetPublicKey($pubkey);

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

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

?>