(PHP Extension) Find a Certificate in the "Other People" Windows Certificate Store
Demonstrates how to open the "Current User --> Other People" Windows certificate store, and locates a certificate matching an email address. Note: This example requires Chilkat v10.1.2 or greater.
<?php
include("chilkat.php");
// Use "chilkat_9_5_0.php" for versions of Chilkat < 10.0.0
$certStore = new CkCertStore();
// The "AddressBook" is the "Other People" certificate store as shown in certmgr.msc
$readOnly = true;
$success = $certStore->OpenWindowsStore('CurrentUser','AddressBook',$readOnly);
if ($success != true) {
print $certStore->lastErrorText() . "\n";
exit;
}
// Find the certificate for the email address:
$jsonE = new CkJsonObject();
$jsonE->UpdateString('email','joe@example.com');
$cert = new CkCert();
$success = $certStore->FindCert($jsonE,$cert);
if ($success == false) {
print $certStore->lastErrorText() . "\n";
exit;
}
print 'Found certificate: ' . $cert->subjectDN() . "\n";
?>
|