From cfae5b75160e47c94ce0798fa2d4213a44ddfefb Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Thu, 21 Feb 2019 14:18:00 +0100 Subject: [PATCH] fix deleting of certificate when certificate is froxor-vhost-certificate Signed-off-by: Michael Kaufmann --- lib/Froxlor/Api/Commands/Certificates.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/Froxlor/Api/Commands/Certificates.php b/lib/Froxlor/Api/Commands/Certificates.php index ea4dbff8..a4173ba5 100644 --- a/lib/Froxlor/Api/Commands/Certificates.php +++ b/lib/Froxlor/Api/Commands/Certificates.php @@ -240,12 +240,27 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou $params['aid'] = $this->getUserDetail('adminid'); } $chk = Database::pexecute_first($chk_stmt, $params); + if ($chk == false && $this->getUserDetail('change_serversettings')) { + // check whether it might be the froxlor-vhost certificate + $chk_stmt = Database::prepare(" + SELECT \"" . Settings::Get('system.hostname') . "\" as domain FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` + WHERE `id` = :id AND `domainid` = '0'"); + $params = array( + 'id' => $id + ); + $chk = Database::pexecute_first($chk_stmt, $params); + $chk['isFroxlorVhost'] = true; + } } if ($chk !== false) { // additional access check by trying to get the certificate - $result = $this->apiCall('Certificates.get', array( - 'domainname' => $chk['domain'] - )); + if (isset($chk['isFroxlorVhost']) && $chk['isFroxlorVhost'] == true) { + $result = $chk; + } else { + $result = $this->apiCall('Certificates.get', array( + 'domainname' => $chk['domain'] + )); + } $del_stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` WHERE id = :id"); Database::pexecute($del_stmt, array( 'id' => $id @@ -253,6 +268,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou $this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_INFO, "[API] removed ssl-certificate for '" . $chk['domain'] . "'"); return $this->response(200, "successfull", $result); } + throw new \Exception("Unable to determine SSL certificate. Maybe no access?", 406); } /**