Sample code for 30+ languages & platforms
PHP Extension

Get Certificate Policy

See more Certificates Examples

Demonstrates how to get a certificate's policy OIDs (if any)

Chilkat PHP Extension Downloads

PHP Extension
<?php

include("chilkat.php");

$success = false;

$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";
}


?>