#!/usr/local/bin/php
=gentitle("System: Advanced functions");?>
document.forms[0].status.value=\"Creating CA...\";";
mwexec("rm -rf /tmp/*");
//mwexec("rm -rf /tmp/newcerts");
safe_mkdir("/tmp/newcerts", 0755);
touch("/tmp/index.txt");
$fd = fopen("/tmp/serial","w");
fwrite($fd, "01\n");
fclose($fd);
/*
mkdir /tmp/newcerts
touch /tmp/index.txt
echo 01 > serial
#Create The Certificate Authority Root Certificate
cd /tmp/ && openssl req -nodes -new -x509 -keyout cakey.pem -out cacert.pem -config /etc/ssl/openssl.cnf
#Create User Certificates
cd /tmp/ && openssl req -nodes -new -keyout vpnkey.pem -out vpncert-req.pem -config /etc/ssl/openssl.cnf
mkdir /tmp/newcerts
openssl ca -out vpncert.pem -in vpncert-req.pem -batch
# Diffie-Hellman Parameters (tls-server only)
dh dh1024.pem
# Root certificate
ca CA-DB/cacert.pem
# Server certificate
cert vpncert.pem
# Server private key
key vpnkey.pem
*/
execute_command_return_output("/usr/bin/openssl req -nodes -new -x509 -keyout /tmp/cakey.pem -out /tmp/cacert.pem -config /etc/ssl/openssl.cnf");
echo "\n";
execute_command_return_output("/usr/bin/openssl req -nodes -new -keyout /tmp/vpnkey.pem -out /tmp/vpncert-req.pem -config /etc/ssl/openssl.cnf");
execute_command_return_output("/usr/bin/openssl ca -out /tmp/vpncert.pem -in /tmp/vpncert-req.pem -batch");
echo "\n";
execute_command_return_output("/usr/bin/openssl dhparam -out /tmp/dh1024.pem 1024");
echo "\n";
//CLIENT
//mwexec("openssl req -nodes -new -keyout home.key -out home.csr");
//mwexec("openssl ca -out home.crt -in home.csr");
$cacertA = get_file_contents("/tmp/cacert.pem");
$serverkeyA = get_file_contents("/tmp/vpnkey.pem");
$servercertA = get_file_contents("/tmp/vpncert.pem");
$dhpemA = get_file_contents("/tmp/dh1024.pem");
$cacert = ereg_replace("\n","\\n", $cacertA);
$serverkey = ereg_replace("\n","\\n", $serverkeyA);
$dhpem = ereg_replace("\n","\\n", $dhpemA);
//$servercert = ereg_replace("\n","\\n", $servercertA);
$tmp = strstr($servercertA, "-----BEGIN CERTIFICATE-----");
$servercert = ereg_replace("\n","\\n", $tmp);
?>
=gentitle("OpenVPN: Create Certificates");?>