(PHP Extension) Get Certificate Policy
Demonstrates how to get a certificate's policy OIDs (if any)
<?php
// The version number (9_5_0) should match version of the Chilkat extension used, omitting the micro-version number.
// For example, if using Chilkat v9.5.0.48, then include as shown here:
include("chilkat_9_5_0.php");
$cert = new CkCert();
$success = $cert->LoadFromFile('qa_data/certs/sample.cer');
if ($success == false) {
print $cert->lastErrorText() . "\n";
exit;
}
// The certificatePolicies OID is 2.5.29.32
$oid = '2.5.29.32';
$strXml = $cert->getExtensionAsXml($oid);
if ($cert->get_LastMethodSuccess() == true) {
print $strXml . "\n";
// Sample result:
// <sequence><sequence><oid>2.16.840.1.101.2.1.11.39</oid></sequence></sequence>
$xml = new CkXml();
$xml->LoadXml($strXml);
print 'Policy OID = ' . $xml->getChildContent('sequence|oid') . "\n";
}
?>
|