reverseproxy: notify cert change only in cron job

notifying this in ensureCertificate does not work if provider changed in the middle anyway.
might as well get them to be in sync in the cronjob.

this change also resulted in tls addon getting restarted non-stop if you change from wildcard
to non-wildcard since ensureCertificate notifies the change.
This commit is contained in:
Girish Ramakrishnan
2022-11-30 15:16:16 +01:00
parent 69b46d82ab
commit f27847950c
4 changed files with 39 additions and 29 deletions
+4 -5
View File
@@ -32,7 +32,7 @@ exports = module.exports = {
startMail,
restartMail,
handleCertChanged,
checkCertificate,
getMailAuth,
sendTestMail,
@@ -812,15 +812,14 @@ async function restartMailIfActivated() {
await restartMail();
}
async function handleCertChanged() {
debug('handleCertChanged: will restart if activated');
async function checkCertificate() {
const certificate = await reverseProxy.getMailCertificate();
const cert = safe.fs.readFileSync(`${paths.MAIL_CONFIG_DIR}/tls_cert.pem`, { encoding: 'utf8' });
if (cert === certificate.cert) {
debug('handleCertChanged: certificate has not changed');
debug('checkCertificate: certificate has not changed');
return;
}
debug('handleCertChanged: certificate has changed');
debug('checkCertificate: certificate has changed');
await restartMailIfActivated();
}