PHP Requires Chilkat v10.1.2+
Chilkat2 PHP
Load PFX/P12 File into Certificate Store Object
Demonstrates how to load a .pfx/.p12 into a certificate store object.Chilkat PHP Downloads
<?php
use Chilkat2\Cert;
use Chilkat2\CertStore;
$certStore = new CertStore();
// This only loads the contents of the PFX file into the certStore object.
// It is not importing the PFX into the Windows certificate stores.
$pfxPassword = 'badssl.com';
try {
$certStore->LoadPfxFile('qa_data/pfx/badssl.com-client.p12', $pfxPassword);
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
// Examine each certificate (loaded from the PFX) in this certStore object
$cert = new Cert();
$numCerts = $certStore->NumCertificates;
$i = 0;
while ($i < $numCerts) {
$certStore->GetCert($i, $cert);
echo 'hasPrivateKey=', ($cert->HasPrivateKey() ? 'true' : 'false'), ', ', $cert->SubjectCN, "\n";
$i = $i + 1;
}