Skip to content

Commit 770ad40

Browse files
author
Marius Burkard
committed
Merge branch 'nginx_TLSv1.3_detection' into 'develop'
Adds TLSv1.3 detection & support to Nginx See merge request ispconfig/ispconfig3!1251
2 parents 46e6474 + 3b3762f commit 770ad40

File tree

3 files changed

+66
-1
lines changed

3 files changed

+66
-1
lines changed

server/conf/nginx_vhost.conf.master

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@ server {
1818
listen <tmpl_var name='ip_address'>:<tmpl_var name='proxy_protocol_https'> ssl proxy_protocol;
1919
</tmpl_if>
2020
</tmpl_if>
21-
ssl_protocols TLSv1.2;
21+
22+
<tmpl_if name='tls1.3_supported' op='==' value='y'>
23+
<tmpl_var name="ssl_protocols">
24+
ssl_protocols TLSv1.3 TLSv1.2;
25+
<tmpl_else>
26+
<tmpl_var name="ssl_protocols">
27+
ssl_protocols TLSv1.2;
28+
</tmpl_if>
2229
# ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
2330
# ssl_prefer_server_ciphers on;
2431
<tmpl_if name='ipv6_enabled'>

server/lib/classes/system.inc.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2142,6 +2142,52 @@ function getinitcommand($servicename, $action, $init_script_directory = '', $che
21422142
}
21432143
}
21442144

2145+
function getopensslversion($get_minor = false) {
2146+
global $app;
2147+
if($this->is_installed('openssl')) $cmd = 'openssl version';
2148+
else {
2149+
$app->log("Could not check OpenSSL version, openssl not found.", LOGLEVEL_DEBUG);
2150+
return '1.0.1';
2151+
}
2152+
2153+
exec($cmd, $output, $return_var);
2154+
if($return_var != 0 || !$output[0]) {
2155+
$app->log("Could not check OpenSSL version, openssl did not return any data.", LOGLEVEL_WARN);
2156+
return '1.0.1';
2157+
}
2158+
if(preg_match('/OpenSSL\s*(\d+)(\.(\d+)(\.(\d+))*)?(\D|$)/i', $output[0], $matches)) {
2159+
return $matches[1] . (isset($matches[3]) ? '.' . $matches[3] : '') . (isset($matches[5]) && $get_minor == true ? '.' . $matches[5] : '');
2160+
} else {
2161+
$app->log("Could not check OpenSSL version, did not find version string in openssl output.", LOGLEVEL_WARN);
2162+
return '1.0.1';
2163+
}
2164+
2165+
}
2166+
2167+
function getnginxversion($get_minor = false) {
2168+
global $app;
2169+
2170+
if($this->is_installed('nginx')) $cmd = 'nginx -v 2>&1';
2171+
else {
2172+
$app->log("Could not check Nginx version, nginx not found.", LOGLEVEL_DEBUG);
2173+
return false;
2174+
}
2175+
2176+
exec($cmd, $output, $return_var);
2177+
2178+
if($return_var != 0 || !$output[0]) {
2179+
$app->log("Could not check Nginx version, nginx did not return any data.", LOGLEVEL_WARN);
2180+
return false;
2181+
}
2182+
2183+
if(preg_match('/nginx version: nginx\/\s*(\d+)(\.(\d+)(\.(\d+))*)?(\D|$)/i', $output[0], $matches)) {
2184+
return $matches[1] . (isset($matches[3]) ? '.' . $matches[3] : '') . (isset($matches[5]) && $get_minor == true ? '.' . $matches[5] : '');
2185+
} else {
2186+
$app->log("Could not check Nginx version, did not find version string in nginx output.", LOGLEVEL_WARN);
2187+
return false;
2188+
}
2189+
}
2190+
21452191
function getapacheversion($get_minor = false) {
21462192
global $app;
21472193

server/plugins-available/nginx_plugin.inc.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,18 @@ function update($event_name, $data) {
16211621
// set logging variable
16221622
$vhost_data['logging'] = $web_config['logging'];
16231623

1624+
// Provide TLS 1.3 support if Nginx version is >= 1.13.0 and when it was linked against OpenSSL(>=1.1.1) at build time.
1625+
$output = $app->system->exec_safe('nginx -V 2>&1');
1626+
1627+
if(preg_match('/built with OpenSSL\s*(\d+)(\.(\d+)(\.(\d+))*)?(\D|$)/i', $output[0], $matches)) {
1628+
$nginx_openssl_ver = $matches[1] . (isset($matches[3]) ? '.' . $matches[3] : '') . (isset($matches[5]) ? '.' . $matches[5] : '');
1629+
}
1630+
1631+
if((version_compare($app->system->getnginxversion(true), '1.13.0', '>=') && version_compare($nginx_openssl_ver, '1.1.1', '>='))) {
1632+
$app->log('Enable TLS 1.3 for: '.$domain, LOGLEVEL_DEBUG);
1633+
$vhost_data['tls1.3_supported'] = 'y';
1634+
}
1635+
16241636
$tpl->setVar($vhost_data);
16251637

16261638
$server_alias = array();

0 commit comments

Comments
 (0)