PHP
Chilkat2 PHP
Find Certificate by SHA1 Thumbprint
See more Cert Store Examples
Demonstrates how to find a certificate having the specified hexadecimal SHA1 thumbprint.Note: Requires Chilkat v10.1.2 or later.
Chilkat PHP Downloads
<?php
use Chilkat2\Cert;
use Chilkat2\CertStore;
use Chilkat2\JsonObject;
$certStore = new CertStore();
// This opens the Current User certificate store on Windows,
// On MacOS and iOS it opens the default Keychain.
$readOnly = false;
try {
$certStore->OpenCurrentUserStore($readOnly);
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
// Find the certificate having a specific SHA1 thumbprint.
$json = new JsonObject();
$hexThumbprint = '767192374BE3C1512D2CB80734926D40E96D6DC2';
$json->UpdateString('thumbprint', $hexThumbprint);
$cert = new Cert();
try {
$certStore->FindCert($json, $cert);
// Show the full distinguished name of the certificate.
echo 'Found: ', $cert->SubjectDN, "\n";
} catch (\Chilkat2\Exception $e) {
echo "Not found.\n";
}