froxlor / Froxlor

The server administration software for your needs - The official Froxlor development Git repository
http://www.froxlor.org
GNU General Public License v2.0
1.62k stars 455 forks source link

SSL deactivated for specific domain, but still trying to get one from Letsencrypt #1241

Closed mjunghanns closed 5 months ago

mjunghanns commented 5 months ago

Describe the bug I ran into a problem with a specific domain. Since this domain is not being actively used at the moment, I disabled the use of SSL in the domain's configuration. To my surprise, Froxlor was still trying to obtain a certificate from Letsencrypt. I was able to overcome this by re-enabling the use of SSL for that domain, then actively deactivate the option "Create SSL certificate (Let's Encrypt)" and then deactive the use of SSL altogether for this specific domain.

System information

To Reproduce Steps to reproduce the behavior: Prerequisite: A specific domain has SSL enabled and "Create SSL certificate (Let's Encrypt)" enabled

  1. Go to 'Ressources'->'Domains', select 'Edit' on specific Domain
  2. Deactivate SSL for this domain by disabling 'Create SSL certificate (Let's Encrypt)'
  3. Scroll down to bottom, click "Save"

Despite SSL being disabled, the cronjob still tries to obtain a SSL certificate from Let's Encrypt every time it runs.

Expected behavior Once SSL is deactivated, I would expect Froxlor to not trying to obtain a SSL certificate from Let's Encrypt. I would expect SSL to be disabled alltogether for the specific domain.

d00p commented 5 months ago

Can you verify that the following patch resolves the issue?

diff --git a/lib/Froxlor/Api/Commands/Domains.php b/lib/Froxlor/Api/Commands/Domains.php
index 8559e6e5..ad0d4c55 100644
--- a/lib/Froxlor/Api/Commands/Domains.php
+++ b/lib/Froxlor/Api/Commands/Domains.php
@@ -1528,13 +1528,12 @@ class Domains extends ApiCommand implements ResourceEntity
                                // enabled ssl for the domain but no ssl ip/port is selected
                                Response::standardError('nosslippportgiven', '', true);
                        }
-                       if (Settings::Get('system.use_ssl') == "0" || empty($ssl_ipandports)) {
+                       if (Settings::Get('system.use_ssl') == "0" || empty($ssl_ipandports) || !$sslenabled) {
                                $ssl_redirect = 0;
                                $letsencrypt = 0;
                                $http2 = 0;
-                               // we need this for the json_encode
-                               // if ssl is disabled or no ssl-ip/port exists
-                               $ssl_ipandports[] = -1;
+                               // act like $remove_ssl_ipandport
+                               $ssl_ipandports = [];

                                // HSTS
                                $hsts_maxage = 0;
mjunghanns commented 5 months ago

Hello Michael, excellent! That did the trick! It is now working as expected. Thank you!