From 81689d80bf0b7d146a8707ee7137236b7e4ee778 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 22 Jun 2024 15:50:56 +0200 Subject: [PATCH] Add the TLS check to the test script --- wcfsetup/install/lang/de.xml | 2 +- wcfsetup/install/lang/en.xml | 2 +- wcfsetup/test.php | 31 +++++++++++++++++++++++++++++-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 2130bd9a57..590357b715 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -984,7 +984,7 @@ Sie erreichen das Fehlerprotokoll unter: {link controller='ExceptionLogView' isE Liste der fehlenden Texte für weitere Informationen.]]> Systemüberprüfung durchzuführen.]]> - + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 7f07b3a0b5..51174254ed 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -962,7 +962,7 @@ You can access the error log at: {link controller='ExceptionLogView' isEmail=tru list of missing phrases for more information.]]> System Check.]]> - + diff --git a/wcfsetup/test.php b/wcfsetup/test.php index 919afb7bf7..f6c41db894 100644 --- a/wcfsetup/test.php +++ b/wcfsetup/test.php @@ -11,7 +11,7 @@ if (isset($_GET['language']) && \in_array($_GET['language'], ['de', 'en'])) { $language = $_GET['language']; } -const WSC_SRT_VERSION = '6.0.0'; +const WSC_SRT_VERSION = '6.1.0'; $requiredExtensions = [ 'ctype', 'dom', @@ -82,6 +82,10 @@ $phrases = [ 'de' => 'Bitte stellen Sie sicher, dass MySQL 8.0.30+ oder MariaDB 10.5.15+ mit InnoDB-Unterstützung vorhanden ist.', 'en' => 'Please make sure that MySQL 8.0.30+ or MariaDB 10.5.15+, with InnoDB support is available.', ], + 'tls_failure' => [ + 'de' => 'Die Seite wird nicht über HTTPS aufgerufen. Wichtige Funktionen stehen dadurch nicht zur Verfügung, die für die korrekte Funktionsweise der Software erforderlich sind.', + 'en' => 'The page is not accessed via HTTPS. Important features that are required for the proper operation of the software are therefore not available.', + ], 'result' => [ 'de' => 'Ergebnis', 'en' => 'Summary', @@ -185,7 +189,7 @@ function checkResult() { global $requiredExtensions; - if (!checkPHPVersion() || !checkX64() || !checkMemoryLimit() || !checkOpcache()) { + if (!checkPHPVersion() || !checkX64() || !checkMemoryLimit() || !checkOpcache() || !checkTls()) { return false; } @@ -224,6 +228,25 @@ function checkOpcache() return true; } +function checkTls(): bool +{ + // @see \wcf\system\request\RouteHandler::secureConnection() + if ( + (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') + || $_SERVER['SERVER_PORT'] == 443 + || (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') + ) { + return true; + } + + // @see \wcf\system\request\RouteHandler::secureContext() + $host = $_SERVER['HTTP_HOST']; + if ($host === '127.0.0.1' || $host === 'localhost' || \str_ends_with($host, '.localhost')) { + return true; + } + + return false; +} ?> @@ -482,6 +505,10 @@ function checkOpcache()
  • + + +
  • +
  • -- 2.20.1