(PHP Extension) Iterate over Certificates in a Certificate Store
Demonstrates how to iterate over the certificates in a certificate store.
Note: Requires Chilkat v10.1.2 or later.
<?php
include("chilkat.php");
// Use "chilkat_9_5_0.php" for versions of Chilkat < 10.0.0
$certStore = new CkCertStore();
// This opens the Current User certificate store on Windows,
// On MacOS and iOS it opens the default Keychain.
$readOnly = false;
$success = $certStore->OpenCurrentUserStore($readOnly);
if ($success == false) {
print $certStore->lastErrorText() . "\n";
exit;
}
$cert = new CkCert();
$numCerts = $certStore->get_NumCertificates();
$i = 0;
while ($i < $numCerts) {
// Load the cert object with the Nth certificate.
$certStore->GetCert($i,$cert);
print $i . ': ' . $cert->subjectCN() . "\n";
$i = $i + 1;
}
?>
|