PHP
Chilkat2 PHP
Get Certificate Policy
See more Certificates Examples
Demonstrates how to get a certificate's policy OIDs (if any)Chilkat PHP Downloads
<?php
use Chilkat2\Cert;
use Chilkat2\Xml;
$cert = new Cert();
try {
$cert->LoadFromFile('qa_data/certs/sample.cer');
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
// The certificatePolicies OID is 2.5.29.32
$oid = '2.5.29.32';
try {
$strXml = $cert->GetExtensionAsXml($oid);
} catch (\Chilkat2\Exception $e) {
$strXml = null;
}
if ($strXml !== null) {
echo $strXml, "\n";
// Sample result:
// <sequence><sequence><oid>2.16.840.1.101.2.1.11.39</oid></sequence></sequence>
$xml = new Xml();
$xml->LoadXml($strXml);
echo 'Policy OID = ', $xml->GetChildContent('sequence|oid'), "\n";
}