create self-signed certificate as last fallback if system-wide cert/key file cannot be found; add english translations for installation (wip)

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-05-02 19:16:58 +02:00
parent c4a2d87d70
commit f8386062cf
9 changed files with 117 additions and 64 deletions

View File

@@ -36,6 +36,7 @@ use Froxlor\Http\Statistics;
use Froxlor\PhpHelper;
use Froxlor\Settings;
use Froxlor\Validate\Validate;
use Froxlor\System\Crypt;
use PDO;
/**
@@ -351,9 +352,8 @@ class Apache extends HttpConfigBase
if (($row_ipsandports['ssl_cert_file'] == '' || !file_exists($row_ipsandports['ssl_cert_file'])) && (Settings::Get('system.le_froxlor_enabled') == '0' || $this->froxlorVhostHasLetsEncryptCert() == false)) {
$row_ipsandports['ssl_cert_file'] = Settings::Get('system.ssl_cert_file');
if (!file_exists($row_ipsandports['ssl_cert_file'])) {
// explicitly disable ssl for this vhost
$row_ipsandports['ssl_cert_file'] = "";
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Disabling SSL-vhost for "' . Settings::Get('system.hostname') . '"');
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Creating self-signed certificate...');
Crypt::createSelfSignedCertificate();
}
}

View File

@@ -35,6 +35,7 @@ use Froxlor\Http\Directory;
use Froxlor\Http\Statistics;
use Froxlor\Settings;
use Froxlor\Validate\Validate;
use Froxlor\System\Crypt;
use PDO;
/**
@@ -212,9 +213,16 @@ class Lighttpd extends HttpConfigBase
if (($row_ipsandports['ssl_cert_file'] == '' || !file_exists($row_ipsandports['ssl_cert_file'])) && (Settings::Get('system.le_froxlor_enabled') == '0' || $this->froxlorVhostHasLetsEncryptCert() == false)) {
$row_ipsandports['ssl_cert_file'] = Settings::Get('system.ssl_cert_file');
if (!file_exists($row_ipsandports['ssl_cert_file'])) {
$this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Creating self-signed certificate...');
Crypt::createSelfSignedCertificate();
}
}
if ($row_ipsandports['ssl_key_file'] == '') {
$row_ipsandports['ssl_key_file'] = Settings::Get('system.ssl_key_file');
if (!file_exists($row_ipsandports['ssl_key_file'])) {
// explicitly disable ssl for this vhost
$row_ipsandports['ssl_cert_file'] = "";
$this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Disabling SSL-vhost for "' . Settings::Get('system.hostname') . '"');
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate key-file "' . Settings::Get('system.ssl_key_file') . '" does not seem to exist. Disabling SSL-vhost for "' . Settings::Get('system.hostname') . '"');
}
}

View File

@@ -35,6 +35,7 @@ use Froxlor\Http\Directory;
use Froxlor\Http\Statistics;
use Froxlor\Settings;
use Froxlor\Validate\Validate;
use Froxlor\System\Crypt;
use PDO;
class Nginx extends HttpConfigBase
@@ -110,9 +111,8 @@ class Nginx extends HttpConfigBase
if (($row_ipsandports['ssl_cert_file'] == '' || !file_exists($row_ipsandports['ssl_cert_file'])) && (Settings::Get('system.le_froxlor_enabled') == '0' || $this->froxlorVhostHasLetsEncryptCert() == false)) {
$row_ipsandports['ssl_cert_file'] = Settings::Get('system.ssl_cert_file');
if (!file_exists($row_ipsandports['ssl_cert_file'])) {
// explicitly disable ssl for this vhost
$row_ipsandports['ssl_cert_file'] = "";
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Disabling SSL-vhost for "' . Settings::Get('system.hostname') . '"');
FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Creating self-signed certificate...');
Crypt::createSelfSignedCertificate();
}
}
if ($row_ipsandports['ssl_key_file'] == '') {

View File

@@ -29,6 +29,7 @@ use Exception;
use Froxlor\Install\Install\Core;
use Froxlor\UI\Panel\UI;
use Froxlor\UI\Request;
use Froxlor\Config\ConfigParser;
class Install
{
@@ -42,18 +43,29 @@ class Install
public array $suggestions = [];
public array $criticals = [];
public array $loadedExtensions;
// TODO: add more os
public array $supportedOS = [
'focal' => 'Ubuntu 20.04 LTS (Focal Fossa)'
];
public array $supportedOS = [];
public array $webserverBackend = [
'php-fpm' => 'PHP-FPM',
'fcgid' => 'FCGID',
'none' => 'None',
'mod_php' => 'mod_php (not recommended)',
];
public function __construct()
{
// get all supported OS
// show list of available distro's
$distros = glob(dirname(__DIR__, 3) . '/lib/configfiles/*.xml');
$distributions_select[''] = '-';
// read in all the distros
foreach ($distros as $distribution) {
// get configparser object
$dist = new ConfigParser($distribution);
// store in tmp array
$this->supportedOS[str_replace(".xml", "", strtolower(basename($distribution)))] = $dist->getCompleteDistroName();
}
// sort by distribution name
asort($this->supportedOS);
// set formfield, so we can get the fields and steps etc.
$this->formfield = require dirname(__DIR__, 3) . '/lib/formfields/install/formfield.install.php';
@@ -131,7 +143,7 @@ class Install
}
// also handle completion of installation if it's the step before the last step
if ($this->currentStep == ($this->maxSteps -1)) {
if ($this->currentStep == ($this->maxSteps - 1)) {
$core = new Core($_SESSION['installation']);
$core->doInstall();
}
@@ -180,10 +192,10 @@ class Install
private function getInformationText(): string
{
if (version_compare($this->requiredVersion, PHP_VERSION, "<")) {
$text = 'Your system is running with PHP ' . $this->phpVersion;
$text = lng('install.phpinfosuccess', [$this->phpVersion]);
} else {
$text = 'Your system is running a lower version than PHP ' . $this->requiredVersion;
$this->criticals[] = 'Update your current PHP Version from ' . $this->phpVersion . ' to ' . $this->requiredVersion . ' or higher';
$text = lng('install.phpinfowarn', [$this->requiredVersion]);
$this->criticals[] = lng('install.phpinfoupdate', [$this->phpVersion, $this->requiredVersion]);
}
return $text;
}