Sample code for 30+ languages & platforms
PHP

Load PEM Format Certificate (.pem)

See more Certificates Examples

Loads a PEM format digital certificate and fetches information about the cert.

Chilkat PHP Downloads

PHP
<?php

use Chilkat2\Cert;

$cert = new Cert();

// LoadFromFile will load virtually any certificate format file.
// It will auto-recognize the format and load appropiately.

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

// DN = "Distinguished Name"
echo 'SubjectDN:', $cert->SubjectDN, "\n";

echo 'Common Name:', $cert->SubjectCN, "\n";
echo 'Issuer Common Name:', $cert->IssuerCN, "\n";

echo 'Serial Number:', $cert->SerialNumber, "\n";