PHP Extension
PHP Extension
Find Certificate by Email Address
Locate the certificate containing the specified email address in either the RFC822 Name or the Subject.Note: This example requires Chilkat v10.1.2 or later.
Chilkat PHP Extension Downloads
<?php
include("chilkat.php");
$success = false;
$certStore = new CkCertStore();
// This opens the Current User certificate store on Windows,
// On MacOS and iOS it opens the default Keychain.
$readOnly = true;
$success = $certStore->OpenCurrentUserStore($readOnly);
if ($success == false) {
print $certStore->lastErrorText() . "\n";
exit;
}
// Locate the certificate containing the specified email address in either the RFC822 Name or the Subject.
$json = new CkJsonObject();
$email_address = 'harold@example.com';
$json->UpdateString('email',$email_address);
$cert = new CkCert();
$success = $certStore->FindCert($json,$cert);
if ($success == true) {
// Show the full distinguished name of the certificate.
print 'Found: ' . $cert->subjectDN() . "\n";
}
else {
print 'Not found.' . "\n";
}
?>