]> git.mxchange.org Git - friendica.git/commitdiff
Issue 10514: add TLS check to the installer
authorTobias Diekershoff <tobias.diekershoff@gmx.net>
Mon, 16 Aug 2021 17:05:27 +0000 (19:05 +0200)
committerTobias Diekershoff <tobias.diekershoff@gmx.net>
Tue, 17 Aug 2021 06:38:06 +0000 (08:38 +0200)
This PR adds a check to the installer which tries to determine whether the
request to the installer was made over an HTTPS line or not.

I've only tested it with an Apache2 server, but there it works.

Addresses #10514

src/Core/Installer.php

index b2b84c6182eaa76e3618c87463e21d4470631972..355513ac7480960b240bb4e536367f097ee1de7b 100644 (file)
@@ -129,6 +129,10 @@ class Installer
                        $returnVal = false;
                }
 
+               if (!$this->checkTLS()) {
+                       $returnVal = false;
+               }
+
                if (!$this->checkKeys()) {
                        $returnVal = false;
                }
@@ -580,6 +584,38 @@ class Installer
                return $status;
        }
 
+       /**
+        * TLS Check
+        *
+        * Tries to determine wheather the connection to the server is secured
+        * by TLS or not. If not the user will be warned that it is higly
+        * encuraged to use TLS.
+        *
+        * @return bool (true) as TLS is not mandatory
+        */
+       public function checkTLS()
+       {
+               $tls = false;
+
+               if (isset($_SERVER['HTTPS'])) {
+                       if (($_SERVER['HTTPS'] == 1) || ($_SERVER['HTTPS'] == 'on')) {
+                               $tls = true;
+                       }
+               }
+               
+               if (!$tls) {
+                       $help = DI::l10n()->t('The detection of TLS to secure the communication between the browser and the new Friendica server failed.');
+                       $help .= ' ' . DI::l10n()->t('Please ensure that the connection to the server is secure.');
+                       $this->addCheck(DI::l10n()->t('No TLS detected'), $tls, false, $help);
+               } else {
+                       $this->addCheck(DI::l10n()->t('TLS detected'), $tls, false, '');
+               }
+
+
+               // TLS is not required
+               return true;
+       }
+
        /**
         * Imagick Check
         *