Sample code for 30+ languages & platforms
PHP ActiveX

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

PHP ActiveX
<?php

$success = 0;

$certStore = new COM("Chilkat.CertStore");

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

$numCerts = $certStore->NumCertificates;

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

$cert = new COM("Chilkat.Cert");
$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;
}


?>