(PHP Extension) Load PFX (PKCS#12) and List Certificates
Loads a PFX file (.pfx, .p12) and iterates over the certificates found within.
<?php
include("chilkat.php");
// Use "chilkat_9_5_0.php" for versions of Chilkat < 10.0.0
$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";
$i = 0;
while ($i < $numCerts) {
// cert is a CkCert
$cert = $certStore->GetCertificate($i);
print $i . ': (Common Name) ' . $cert->subjectCN() . "\n";
print $i . ': (Serial Number) ' . $cert->serialNumber() . "\n";
print $i . ': (Distinguished Name) ' . $cert->subjectDN() . "\n";
$i = $i + 1;
}
?>
|