(PHP ActiveX) 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
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.CertStore')
$certStore = new COM("Chilkat.CertStore");
// The "AddressBook" is the "Other People" certificate store as shown in certmgr.msc
$readOnly = 1;
$success = $certStore->OpenWindowsStore('CurrentUser','AddressBook',$readOnly);
if ($success != 1) {
print $certStore->LastErrorText . "\n";
exit;
}
// Find the certificate for the email address:
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.JsonObject')
$jsonE = new COM("Chilkat.JsonObject");
$jsonE->UpdateString('email','joe@example.com');
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.Cert')
$cert = new COM("Chilkat.Cert");
$success = $certStore->FindCert($jsonE,$cert);
if ($success == 0) {
print $certStore->LastErrorText . "\n";
exit;
}
print 'Found certificate: ' . $cert->SubjectDN . "\n";
?>
|