(PHP Extension) Apple Keychain - List Certificates
Iterates over the certificates in the Apple Keychain.
Note: This example requires Chilkat v10.0.0 or greater.
<?php
include("chilkat.php");
// Use "chilkat_9_5_0.php" for versions of Chilkat < 10.0.0
$certStore = new CkCertStore();
// On MacOS and iOS, the OpenCurrentUserStore method opens the Keychain.
// The argument passed to OpenCurrentUserStore is ignored.
$success = $certStore->OpenCurrentUserStore(false);
if ($success == false) {
print $certStore->lastErrorText() . "\n";
exit;
}
$numCerts = $certStore->get_NumCertificates();
print 'numCerts = ' . $numCerts . "\n";
$i = 0;
while ($i < $numCerts) {
// cert is a CkCert
$cert = $certStore->GetCertificate($i);
print $cert->subjectDN() . "\n";
print $cert->subjectCN() . "\n";
print $cert->serialNumber() . "\n";
print '----' . "\n";
$i = $i + 1;
}
$certStore->CloseCertStore();
?>
|