示例#1
0
function create_openvpn_archive($serial)
{
    global $config;
    create_client_openvpn_config($serial, '.ovpn');
    create_client_openvpn_config($serial, '.conf');
    exec('zip ' . escshellarg($v));
    return ovpn_arch;
}
示例#2
0
function CA_remove_cert($serial)
{
    global $config;
    $userreq = $config['req_dir'] . '/' . $serial . '-req.pem';
    $userkey = $config['private_dir'] . '/' . $serial . '-key.pem';
    $usercert = $config['new_certs_dir'] . '/' . $serial . '.pem';
    $userder = $config['cert_dir'] . '/' . $serial . '.der';
    $userpfx = $config['pfx_dir'] . '/' . $serial . '.pfx';
    # Wait here if another user has the database locked.
    $fd = fopen($config['index'], 'a');
    flock($fd, LOCK_EX);
    if (file_exists($userreq)) {
        unlink($userreq);
    }
    if (file_exists($userkey)) {
        unlink($userkey);
    }
    if (file_exists($usercert)) {
        unlink($usercert);
    }
    if (file_exists($userder)) {
        unlink($userder);
    }
    if (file_exists($userpfx)) {
        unlink($userpfx);
    }
    $tmpfile = $config['index'] . '.tmp';
    copy($config['index'], $tmpfile);
    $regexp = "^[VR]\t.*\t.*\t" . $serial . "\t.*\t.*\$";
    exec('egrep -v ' . escshellarg($regexp) . " {$tmpfile} > " . $config['index'] . " 2>/dev/null");
    unlink($tmpfile);
    fclose($fd);
}