only add lets encrypt certificate if cert is valid; display acme.sh output if --debug is specified
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -307,6 +307,8 @@ class AcmeSh extends \Froxlor\Cron\FroxlorCron
|
|||||||
}
|
}
|
||||||
|
|
||||||
$acme_result = \Froxlor\FileDir::safe_exec($acmesh_cmd);
|
$acme_result = \Froxlor\FileDir::safe_exec($acmesh_cmd);
|
||||||
|
// debug output of acme.sh run
|
||||||
|
$cronlog->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, implode("\n", $acme_result));
|
||||||
|
|
||||||
$return = array();
|
$return = array();
|
||||||
self::readCertificateToVar($certrow['domain'], $return);
|
self::readCertificateToVar($certrow['domain'], $return);
|
||||||
@@ -315,27 +317,31 @@ class AcmeSh extends \Froxlor\Cron\FroxlorCron
|
|||||||
|
|
||||||
$newcert = openssl_x509_parse($return['crt']);
|
$newcert = openssl_x509_parse($return['crt']);
|
||||||
|
|
||||||
// Store the new data
|
if ($newcert) {
|
||||||
Database::pexecute(self::$updcert_stmt, array(
|
// Store the new data
|
||||||
'id' => $certrow['id'],
|
Database::pexecute(self::$updcert_stmt, array(
|
||||||
'domainid' => $certrow['domainid'],
|
'id' => $certrow['id'],
|
||||||
'crt' => $return['crt'],
|
'domainid' => $certrow['domainid'],
|
||||||
'key' => $return['key'],
|
'crt' => $return['crt'],
|
||||||
'ca' => $return['chain'],
|
'key' => $return['key'],
|
||||||
'chain' => $return['chain'],
|
'ca' => $return['chain'],
|
||||||
'csr' => $return['csr'],
|
'chain' => $return['chain'],
|
||||||
'fullchain' => $return['fullchain'],
|
'csr' => $return['csr'],
|
||||||
'expirationdate' => date('Y-m-d H:i:s', $newcert['validTo_time_t'])
|
'fullchain' => $return['fullchain'],
|
||||||
));
|
'expirationdate' => date('Y-m-d H:i:s', $newcert['validTo_time_t'])
|
||||||
|
|
||||||
if ($certrow['ssl_redirect'] == 3) {
|
|
||||||
Database::pexecute(self::$upddom_stmt, array(
|
|
||||||
'domainid' => $certrow['domainid']
|
|
||||||
));
|
));
|
||||||
}
|
|
||||||
|
|
||||||
$cronlog->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, "Updated Let's Encrypt certificate for " . $certrow['domain']);
|
if ($certrow['ssl_redirect'] == 3) {
|
||||||
$changedetected = 1;
|
Database::pexecute(self::$upddom_stmt, array(
|
||||||
|
'domainid' => $certrow['domainid']
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
$cronlog->logAction(FroxlorLogger::CRON_ACTION, LOG_INFO, "Updated Let's Encrypt certificate for " . $certrow['domain']);
|
||||||
|
$changedetected = 1;
|
||||||
|
} else {
|
||||||
|
$cronlog->logAction(FroxlorLogger::CRON_ACTION, LOG_ERR, "Got non-successful Let's Encrypt response for " . $certrow['domain'] . ":\n" . implode("\n", $acme_result));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$cronlog->logAction(FroxlorLogger::CRON_ACTION, LOG_ERR, "Could not get Let's Encrypt certificate for " . $certrow['domain'] . ":\n" . implode("\n", $acme_result));
|
$cronlog->logAction(FroxlorLogger::CRON_ACTION, LOG_ERR, "Could not get Let's Encrypt certificate for " . $certrow['domain'] . ":\n" . implode("\n", $acme_result));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user