예제 #1
0
function delete_csr_from_db($person, $auth_key)
{
    if (!$person->isAuth()) {
        return false;
    }
    /* Verify that the CSR is present */
    try {
        $csr = get_csr_from_db_raw($person->getX509ValidCN(), $auth_key);
    } catch (CSRNotFoundException $csrnfe) {
        echo "No matching CSR found.<BR>\n";
        $msg = "Could not delete CSR from ip " . $_SERVER['REMOTE_ADDR'];
        $msg .= " : " . stripslashes($person->getX509ValidCN()) . " Reason: not found";
        Logger::log_event(LOG_NOTICE, $msg);
        return false;
    } catch (ConfusaGenException $cge) {
        $msg = "Error in deleting CSR (" . htmlentities($auth_key) . ")";
        $msg .= "for user: "******" ";
        $msg .= "Too many hits!";
        Framework::error_output($msg);
        Logger::log_event(LOG_ALERT, $msg);
        return false;
    }
    MDB2Wrapper::update("DELETE FROM csr_cache WHERE auth_key=? AND common_name=?", array('text', 'text'), array($auth_key, $person->getX509ValidCN()));
    $msg = "Dropping csr " . $auth_key . " ";
    $msg .= "for user " . stripslashes($person->getX509ValidCN()) . "  (" . $_SERVER['REMOTE_ADDR'] . ") from csr_cache";
    logger::log_event(LOG_NOTICE, $msg);
    return true;
}