PHP
Chilkat2 PHP
Find Certificate by Subject OU (Organizational Unit)
See more Cert Store Examples
Demonstrates how to find a certificate having the specified subject organizational unit (OU).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 Subject OU = "Secretaria da Receita Federal do Brasil - RFB".
$json = new JsonObject();
$ou = 'Secretaria da Receita Federal do Brasil - RFB';
$json->UpdateString('OU', $ou);
$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";
}