fix deleting of certificate when certificate is froxor-vhost-certificate

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2019-02-21 14:18:00 +01:00
parent 6e81c235d9
commit cfae5b7516

View File

@@ -240,12 +240,27 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
$params['aid'] = $this->getUserDetail('adminid'); $params['aid'] = $this->getUserDetail('adminid');
} }
$chk = Database::pexecute_first($chk_stmt, $params); $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) { if ($chk !== false) {
// additional access check by trying to get the certificate // additional access check by trying to get the certificate
$result = $this->apiCall('Certificates.get', array( if (isset($chk['isFroxlorVhost']) && $chk['isFroxlorVhost'] == true) {
'domainname' => $chk['domain'] $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"); $del_stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` WHERE id = :id");
Database::pexecute($del_stmt, array( Database::pexecute($del_stmt, array(
'id' => $id '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'] . "'"); $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); return $this->response(200, "successfull", $result);
} }
throw new \Exception("Unable to determine SSL certificate. Maybe no access?", 406);
} }
/** /**