<?php

error_reporting(E_ALL);
require 'PKIX/OCSP/OCSPMessage.php';
require 'PKIX/OCSP/Store.php';
//require_once('../PKIX/utils.php');
define('HTTP_OK', 200);
define('HTTP_BAD_REQUEST', 400);
define('HTTP_UNSUPPORTED_MEDIA_TYPE', 415);
define('HTTP_METHOD_NOT_ALLOWED', 405);
class HTTPException extends Exception
{
}
try {
    $cfg = parse_ini_file('/usr/local/etc/OCSPForwarder.ini');
    $reqData = \PKIX\OCSP\Request::receive(array('GET', 'POST'));
    $req = new PKIX\OCSP\Request();
    $req->setData($reqData);
    //  $result = $req->GET("http://localhost/ocsp/OCSPServer.php", "POST");
    $result = $req->send($cfg['upstreamURL'], $cfg['HTTPmethod']);
    foreach ($result['headers'] as $h) {
        header($h);
    }
    echo $result['body'];
    exit;
} catch (\PKIX\OCSP\Exception $e) {
    logException($e);
    switch ($e->getCode()) {
        case \PKIX\OCSP::ERR_MALFORMED_ASN1:
        case \PKIX\OCSP::ERR_INTERNAL_ERROR:
        case \PKIX\OCSP::ERR_TRY_LATER: