Add Openvpn certificate handling and code tidy

This commit is contained in:
John Crisp
2020-02-27 16:17:37 +01:00
parent 99d78dfa12
commit 7688966f98

View File

@@ -624,6 +624,40 @@ EOS;
#
if (! unlink("$store_dir/tmp/openssl.cnf")) print "Can't unlink $store_dir/tmp/openssl.cnf";
#
# Create dhparam files for OpenVPN and others.
#
print '<p><strong>Creating 1024 bit Diffie-Hellman parameters used by OpenVPN.<br>';
print "Saving to $store_dir/dhparam1024.pem.</strong><br>";
$cmd = "openssl dhparam -rand '$config[random]' -out '$config[private_dir]/dhparam1024.pem' 1024";
print $cmd.'<br>';
flush();
flush_exec($cmd,100);
#
# Create a TLS auth key for OpenVPN.
#
if (function_exists('openvpn')) {
print '<p><strong>Creating a TLS authentication key used by OpenVPN.<br>';
print "Saving to $store_dir/takey.pem.</strong><br>";
$cmd = "openvpn --genkey --secret '$config[private_dir]/takey.pem'";
print $cmd.'<br>';
flush();
flush_exec($cmd);
} else {
echo "openvpn is required to generate a takey.pem<br>";
echo "You can create one later like this:<br>";
echo "openvpn --genkey --secret". $config[private_dir] . "/takey.pem<br>";
}
#print '<p><strong>Creating 2048 bit Diffie-Hellman parameters used by OpenVPN.<br>';
#print "Saving to $store_dir/dhparam2048.pem.</strong><br>";
#$cmd = "openssl dhparam -rand '$config[random]' -out '$config[private_dir]/dhparam2048.pem' 2048";
#print $cmd.'<br>';
#flush();
#flush_exec($cmd,200);
#
# Step aside and let the users in (create index.php files).
#
@@ -636,7 +670,11 @@ EOS;
?>
<center>
<h2>Setup is complete. Your CA root certificate as been created.</h2>
<h3><font color=red>SECURITY WARNING!&nbsp;&nbsp; Be sure to run the <cite>secure.sh</cite> shell script as the <strong>root</strong> user.</font></h3>
<?php
if (! getOSInformation()) {
print '<h3><font color=red>SECURITY WARNING!&nbsp;&nbsp; Be sure to run the <cite>secure.sh</cite> shell script as the <strong>root</strong> user.</font></h3>';
}
?>
<p><br><br>
<form action=index.php>
<input type=submit name=submit value="Proceed To The PHPki Main Menu">