(Perl) Load PFX (PKCS#12) and List Certificates
Loads a PFX file (.pfx, .p12) and iterates over the certificates found within.
use chilkat();
$certStore = chilkat::CkCertStore->new();
$pfxPath = "/Users/chilkat/testData/pfx/chilkat_ssl.pfx";
$pfxPassword = "test";
$success = $certStore->LoadPfxFile($pfxPath,$pfxPassword);
if ($success != 1) {
print $certStore->lastErrorText() . "\r\n";
exit;
}
$numCerts = $certStore->get_NumCertificates();
print "PFX contains " . $numCerts . " certificates" . "\r\n";
$i = 0;
while ($i < $numCerts) {
# cert is a Cert
$cert = $certStore->GetCertificate($i);
print $i . ": (Common Name) " . $cert->subjectCN() . "\r\n";
print $i . ": (Serial Number) " . $cert->serialNumber() . "\r\n";
print $i . ": (Distinguished Name) " . $cert->subjectDN() . "\r\n";
$i = $i + 1;
}
|