(PHP Extension) Load PFX/P12 File into Certificate Store Object
Demonstrates how to load a .pfx/.p12 into a certificate store object.
<?php
include("chilkat.php");
// Use "chilkat_9_5_0.php" for versions of Chilkat < 10.0.0
$certStore = new CkCertStore();
// 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';
$success = $certStore->LoadPfxFile('qa_data/pfx/badssl.com-client.p12',$pfxPassword);
if ($success == false) {
print $certStore->lastErrorText() . "\n";
exit;
}
// Examine each certificate (loaded from the PFX) in this certStore object
$numCerts = $certStore->get_NumCertificates();
$i = 0;
while ($i < $numCerts) {
// cert is a CkCert
$cert = $certStore->GetCertificate($i);
print 'hasPrivateKey=' . $cert->HasPrivateKey() . ', ' . $cert->subjectCN() . "\n";
$i = $i + 1;
}
?>
|