(PHP ActiveX) Find Certificate by Serial Number
Demonstrates how to find a certificate having the specified hexadecimal serial number.
Note: Requires Chilkat v10.1.2 or later.
<?php
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.CertStore')
$certStore = new COM("Chilkat.CertStore");
// This example will search the certs on connected USB tokens and smartcards.
$argNotUsed = '';
$success = $certStore->OpenSmartcard($argNotUsed);
if ($success == 0) {
print $certStore->LastErrorText . "\n";
exit;
}
// Find the certificate having a serial number = "48FC93B46055948D36A7C98A89D69416".
$hexSerial = '48FC93B46055948D36A7C98A89D69416';
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.JsonObject')
$json = new COM("Chilkat.JsonObject");
$json->UpdateString('serial',$hexSerial);
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.Cert')
$cert = new COM("Chilkat.Cert");
$success = $certStore->FindCert($json,$cert);
if ($success == 1) {
// Show the serial number and subject CN
print 'Found: ' . $cert->SerialNumber . ', ' . $cert->SubjectCN . "\n";
}
else {
print 'Not found.' . "\n";
}
?>
|