Sample code for 30+ languages & platforms
PHP Extension

Load PFX (PKCS#12) and List Certificates

See more Certificates Examples

Loads a PFX file (.pfx, .p12) and iterates over the certificates found within.

Chilkat PHP Extension Downloads

PHP Extension
<?php

include("chilkat.php");

$success = false;

$certStore = new CkCertStore();

$pfxPath = '/Users/chilkat/testData/pfx/chilkat_ssl.pfx';
$pfxPassword = 'test';
$success = $certStore->LoadPfxFile($pfxPath,$pfxPassword);
if ($success != true) {
    print $certStore->lastErrorText() . "\n";
    exit;
}

$numCerts = $certStore->get_NumCertificates();

print 'PFX contains ' . $numCerts . ' certificates' . "\n";

$cert = new CkCert();
$i = 0;
while ($i < $numCerts) {
    $certStore->GetCert($i,$cert);

    print $i . ': (Common Name) ' . $cert->subjectCN() . "\n";
    print $i . ': (Serial Number) ' . $cert->serialNumber() . "\n";
    print $i . ': (Distinguished Name) ' . $cert->subjectDN() . "\n";

    $i = $i + 1;
}


?>