add task to remove certificate from acme.sh when removed in froxlor; fix issue when mode of certificate generation was not reset to 'issue' and kept trying to 'renew' instead
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -75,7 +75,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
|
|||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$has_cert) {
|
if (! $has_cert) {
|
||||||
$this->addOrUpdateCertificate($domain['id'], $ssl_cert_file, $ssl_key_file, $ssl_ca_file, $ssl_cert_chainfile, true);
|
$this->addOrUpdateCertificate($domain['id'], $ssl_cert_file, $ssl_key_file, $ssl_ca_file, $ssl_cert_chainfile, true);
|
||||||
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_INFO, "[API] added ssl-certificate for '" . $domain['domain'] . "'");
|
$this->logger()->logAction($this->isAdmin() ? \Froxlor\FroxlorLogger::ADM_ACTION : \Froxlor\FroxlorLogger::USR_ACTION, LOG_INFO, "[API] added ssl-certificate for '" . $domain['domain'] . "'");
|
||||||
$result = $this->apiCall('Certificates.get', array(
|
$result = $this->apiCall('Certificates.get', array(
|
||||||
@@ -182,7 +182,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
|
|||||||
* optional specify offset for resultset
|
* optional specify offset for resultset
|
||||||
* @param array $sql_orderby
|
* @param array $sql_orderby
|
||||||
* optional array with index = fieldname and value = ASC|DESC to order the resultset by one or more fields
|
* optional array with index = fieldname and value = ASC|DESC to order the resultset by one or more fields
|
||||||
*
|
*
|
||||||
* @access admin, customer
|
* @access admin, customer
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
* @return string json-encoded array count|list
|
* @return string json-encoded array count|list
|
||||||
@@ -276,7 +276,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
|
|||||||
|
|
||||||
if ($this->isAdmin() == false) {
|
if ($this->isAdmin() == false) {
|
||||||
$chk_stmt = Database::prepare("
|
$chk_stmt = Database::prepare("
|
||||||
SELECT d.domain FROM `" . TABLE_PANEL_DOMAINS . "` d
|
SELECT d.domain, d.letsencrypt FROM `" . TABLE_PANEL_DOMAINS . "` d
|
||||||
LEFT JOIN `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` s ON s.domainid = d.id
|
LEFT JOIN `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` s ON s.domainid = d.id
|
||||||
WHERE s.`id` = :id AND d.`customerid` = :cid
|
WHERE s.`id` = :id AND d.`customerid` = :cid
|
||||||
");
|
");
|
||||||
@@ -286,7 +286,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
|
|||||||
));
|
));
|
||||||
} elseif ($this->isAdmin()) {
|
} elseif ($this->isAdmin()) {
|
||||||
$chk_stmt = Database::prepare("
|
$chk_stmt = Database::prepare("
|
||||||
SELECT d.domain FROM `" . TABLE_PANEL_DOMAINS . "` d
|
SELECT d.domain, d.letsencrypt FROM `" . TABLE_PANEL_DOMAINS . "` d
|
||||||
LEFT JOIN `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` s ON s.domainid = d.id
|
LEFT JOIN `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` s ON s.domainid = d.id
|
||||||
WHERE s.`id` = :id" . ($this->getUserDetail('customers_see_all') == '0' ? " AND d.`adminid` = :aid" : ""));
|
WHERE s.`id` = :id" . ($this->getUserDetail('customers_see_all') == '0' ? " AND d.`adminid` = :aid" : ""));
|
||||||
$params = array(
|
$params = array(
|
||||||
@@ -299,7 +299,7 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
|
|||||||
if ($chk == false && $this->getUserDetail('change_serversettings')) {
|
if ($chk == false && $this->getUserDetail('change_serversettings')) {
|
||||||
// check whether it might be the froxlor-vhost certificate
|
// check whether it might be the froxlor-vhost certificate
|
||||||
$chk_stmt = Database::prepare("
|
$chk_stmt = Database::prepare("
|
||||||
SELECT \"" . Settings::Get('system.hostname') . "\" as domain FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "`
|
SELECT \"" . Settings::Get('system.hostname') . "\" as domain, \"" . Settings::Get('system.le_froxlor_enabled') . "\" as letsencrypt FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "`
|
||||||
WHERE `id` = :id AND `domainid` = '0'");
|
WHERE `id` = :id AND `domainid` = '0'");
|
||||||
$params = array(
|
$params = array(
|
||||||
'id' => $id
|
'id' => $id
|
||||||
@@ -321,13 +321,16 @@ class Certificates extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resou
|
|||||||
Database::pexecute($del_stmt, array(
|
Database::pexecute($del_stmt, array(
|
||||||
'id' => $id
|
'id' => $id
|
||||||
));
|
));
|
||||||
|
// trigger removing of certificate from acme.sh if let's encrypt
|
||||||
|
if ($chk['letsencrypt'] == '1') {
|
||||||
|
\Froxlor\System\Cronjob::inserttask('12', $chk['domain']);
|
||||||
|
}
|
||||||
$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);
|
throw new \Exception("Unable to determine SSL certificate. Maybe no access?", 406);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* insert or update certificates entry
|
* insert or update certificates entry
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -243,9 +243,11 @@ class AcmeSh extends \Froxlor\Cron\FroxlorCron
|
|||||||
|
|
||||||
// customer domains
|
// customer domains
|
||||||
$certrows = $needRenew ? $needRenew['customer_ssl'] : array();
|
$certrows = $needRenew ? $needRenew['customer_ssl'] : array();
|
||||||
$cert_mode = 'issue';
|
|
||||||
foreach ($certrows as $certrow) {
|
foreach ($certrows as $certrow) {
|
||||||
|
|
||||||
|
// initialize mode to 'issue'
|
||||||
|
$cert_mode = 'issue';
|
||||||
|
|
||||||
// set logger to corresponding loginname for the log to appear in the users system-log
|
// set logger to corresponding loginname for the log to appear in the users system-log
|
||||||
$cronlog = FroxlorLogger::getInstanceOf(array(
|
$cronlog = FroxlorLogger::getInstanceOf(array(
|
||||||
'loginname' => $certrow['loginname'],
|
'loginname' => $certrow['loginname'],
|
||||||
|
|||||||
Reference in New Issue
Block a user