(PHP ActiveX) Load PFX (PKCS#12) and List Certificates
Loads a PFX file (.pfx, .p12) and iterates over the certificates found within.
<?php
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.CertStore')
$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";
$i = 0;
while ($i < $numCerts) {
// cert is a Chilkat.Cert
$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;
}
?>
|