Ejemplo n.º 1
0
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:
        case \PKIX\OCSP::ERR_SIG_REQUIRED:
Ejemplo n.º 2
0
<?php

error_reporting(E_ALL);
require 'PKIX/OCSP/OCSPMessage.php';
require 'PKIX/OCSP/Store.php';
//require_once('../PKIX/utils.php');
try {
    //  $storeCfg = array('basedir'	=> '/home/sova/proj/OCSP/data/store');
    $storeCfg = parse_ini_file('/usr/local/etc/OCSPServer.ini');
    $reqData = \PKIX\OCSP\Request::receive(array('GET', 'POST'));
    //  error_log ("main: rdata[".strlen($reqData)."] $reqData");
    $req = new \PKIX\OCSP\Request($reqData);
    /* DBG */
    //  error_log("req: ".var_export($req,true));
    $CertID = $req->getCertID();
    /* DBG */
    //  error_log("CertID: ".var_export($CertID,true));
    $store = new \OCSPServer\StoreFS($storeCfg);
    $respData = $store->getResp($CertID);
    $resp = new \PKIX\OCSP\Response($respData);
    //  $resp->setMaxAge(300);
    $cs = $resp->getCertStatus();
    //  error_log("certStatus:". var_export($cs, true));
    $resp->respond();
    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: