Sample code for 30+ languages & platforms
PHP

Load DER encoded X.509 Certificate (.cer, .crt)

See more Certificates Examples

Loads a digital certificate from a binary DER encoded X.509 Certificate (.cer, .crt) 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/chilkat_ssl.cer');
} 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";