Skip to content

Commit 4ae2a0f

Browse files
committed
Implemented: FS#931 - Optional SSL for Web Interface
1 parent 712706d commit 4ae2a0f

File tree

8 files changed

+75
-2
lines changed

8 files changed

+75
-2
lines changed

install/dist/lib/fedora.lib.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,12 @@ public function install_ispconfig()
824824
$content = str_replace('{vhost_port_listen}', '', $content);
825825
}
826826

827+
if(is_file('/usr/local/ispconfig/interface/ssl/ispserver.crt') && is_file('/usr/local/ispconfig/interface/ssl/ispserver.key')) {
828+
$content = str_replace('{ssl_comment}', '', $content);
829+
} else {
830+
$content = str_replace('{ssl_comment}', '#', $content);
831+
}
832+
827833
wf("$vhost_conf_dir/ispconfig.vhost", $content);
828834

829835
//copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");

install/dist/lib/gentoo.lib.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,12 @@ public function install_ispconfig()
699699
$content = str_replace('{vhost_port_listen}', '', $content);
700700
}
701701

702+
if(is_file('/usr/local/ispconfig/interface/ssl/ispserver.crt') && is_file('/usr/local/ispconfig/interface/ssl/ispserver.key')) {
703+
$content = str_replace('{ssl_comment}', '', $content);
704+
} else {
705+
$content = str_replace('{ssl_comment}', '#', $content);
706+
}
707+
702708
$vhost_path = $conf['apache']['vhost_conf_dir'].'/ispconfig.vhost';
703709
$this->write_config_file($vhost_path, $content);
704710

install/dist/lib/opensuse.lib.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,7 @@ public function configure_firewall()
633633
unset($iptables_location);
634634

635635
}
636-
637-
636+
638637
public function install_ispconfig()
639638
{
640639
global $conf;
@@ -838,6 +837,12 @@ public function install_ispconfig()
838837
$content = str_replace('{vhost_port_listen}', '', $content);
839838
}
840839

840+
if(is_file('/usr/local/ispconfig/interface/ssl/ispserver.crt') && is_file('/usr/local/ispconfig/interface/ssl/ispserver.key')) {
841+
$content = str_replace('{ssl_comment}', '', $content);
842+
} else {
843+
$content = str_replace('{ssl_comment}', '#', $content);
844+
}
845+
841846
$content = str_replace('/var/www/', '/srv/www/', $content);
842847

843848
wf("$vhost_conf_dir/ispconfig.vhost", $content);

install/install.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,10 @@
450450
//** Customise the port ISPConfig runs on
451451
$conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', '8080');
452452

453+
if(strtolower($inst->simple_query('Enable SSL for the ISPConfig web interface',array('y','n'),'y')) == 'y') {
454+
$inst->make_ispconfig_ssl_cert();
455+
}
456+
453457
$inst->install_ispconfig_interface = true;
454458

455459
} else {

install/lib/install.lib.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,24 @@ function get_ispconfig_port_number() {
697697
}
698698
}
699699

700+
/*
701+
* Get the port number of the ISPConfig controlpanel vhost
702+
*/
703+
704+
function is_ispconfig_ssl_enabled() {
705+
global $conf;
706+
$ispconfig_vhost_file = $conf['apache']['vhost_conf_dir'].'/ispconfig.vhost';
707+
708+
if(is_file($ispconfig_vhost_file)) {
709+
$tmp = file_get_contents($ispconfig_vhost_file);
710+
if(stristr($tmp,'SSLCertificateFile')) {
711+
return true;
712+
} else {
713+
return false;
714+
}
715+
}
716+
}
717+
700718

701719

702720
?>

install/lib/installer_base.lib.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,25 @@ public function configure_apps_vhost() {
11661166
}
11671167

11681168
}
1169+
1170+
public function make_ispconfig_ssl_cert() {
1171+
global $conf;
1172+
1173+
$ssl_crt_file = '/usr/local/ispconfig/interface/ssl/ispserver.crt';
1174+
$ssl_csr_file = '/usr/local/ispconfig/interface/ssl/ispserver.csr';
1175+
$ssl_key_file = '/usr/local/ispconfig/interface/ssl/ispserver.key';
1176+
1177+
if(!is_dir('/usr/local/ispconfig/interface/ssl')) exec("mkdir -p /usr/local/ispconfig/interface/ssl");
1178+
1179+
$ssl_pw = substr(md5(mt_rand()),0,6);
1180+
exec("openssl genrsa -des3 -passout pass:$ssl_pw -out $ssl_key_file 4096");
1181+
exec("openssl req -new -passin pass:$ssl_pw -passout pass:$ssl_pw -key $ssl_key_file -out $ssl_csr_file");
1182+
exec("openssl req -x509 -passin pass:$ssl_pw -passout pass:$ssl_pw -key $ssl_key_file -in $ssl_csr_file -out $ssl_crt_file -days 3650");
1183+
exec("openssl rsa -passin pass:$ssl_pw -in $ssl_key_file -out $ssl_key_file.insecure");
1184+
exec("mv $ssl_key_file $ssl_key_file.secure");
1185+
exec("mv $ssl_key_file.insecure $ssl_key_file");
1186+
1187+
}
11691188

11701189
public function install_ispconfig() {
11711190
global $conf;
@@ -1395,6 +1414,12 @@ public function install_ispconfig() {
13951414
} else {
13961415
$content = str_replace('{vhost_port_listen}', '', $content);
13971416
}
1417+
1418+
if(is_file('/usr/local/ispconfig/interface/ssl/ispserver.crt') && is_file('/usr/local/ispconfig/interface/ssl/ispserver.key')) {
1419+
$content = str_replace('{ssl_comment}', '', $content);
1420+
} else {
1421+
$content = str_replace('{ssl_comment}', '#', $content);
1422+
}
13981423

13991424
wf("$vhost_conf_dir/ispconfig.vhost", $content);
14001425

install/tpl/apache_ispconfig.vhost.master

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ NameVirtualHost *:{vhost_port}
4343
SecRuleEngine Off
4444
</IfModule>
4545

46+
# SSL Configuration
47+
{ssl_comment}SSLEngine On
48+
{ssl_comment}SSLCertificateFile /usr/local/ispconfig/interface/ssl/ispserver.crt
49+
{ssl_comment}SSLCertificateKeyFile /usr/local/ispconfig/interface/ssl/ispserver.key
4650

4751
</VirtualHost>
4852

install/update.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,11 @@
308308
$ispconfig_port_number = get_ispconfig_port_number();
309309
$conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', $ispconfig_port_number);
310310

311+
// $ispconfig_ssl_default = (is_ispconfig_ssl_enabled() == true)?'y':'n';
312+
if(strtolower($inst->simple_query('Create new ISPConfig SSL certificate',array('y','n'),'n')) == 'y') {
313+
$inst->make_ispconfig_ssl_cert();
314+
}
315+
311316
$inst->install_ispconfig();
312317

313318
//** Configure Crontab

0 commit comments

Comments
 (0)