From 9c54d1b7184bad39d364b70a34c91fa9e612f17b Mon Sep 17 00:00:00 2001 From: Stephen Crosby Date: Wed, 10 Jan 2024 20:05:50 -0800 Subject: [PATCH] Provide the token model for certificate renewal --- backend/internal/certificate.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/internal/certificate.js b/backend/internal/certificate.js index 28dc8276..42310302 100644 --- a/backend/internal/certificate.js +++ b/backend/internal/certificate.js @@ -8,6 +8,7 @@ const config = require('../lib/config'); const error = require('../lib/error'); const utils = require('../lib/utils'); const certificateModel = require('../models/certificate'); +const tokenModel = require('../models/token'); const dnsPlugins = require('../global/certbot-dns-plugins'); const internalAuditLog = require('./audit-log'); const internalNginx = require('./nginx'); @@ -45,11 +46,11 @@ const internalCertificate = { processExpiringHosts: () => { if (!internalCertificate.intervalProcessing) { internalCertificate.intervalProcessing = true; - logger.info('Renewing SSL certs close to expiry...'); + logger.info('Renewing SSL certs expiring within ' + internalCertificate.renewBeforeExpirationBy[0] + ' ' + internalCertificate.renewBeforeExpirationBy[1] + ' ...'); const expirationThreshold = moment().add(internalCertificate.renewBeforeExpirationBy[0], internalCertificate.renewBeforeExpirationBy[1]).format('YYYY-MM-DD HH:mm:ss'); - // Fetch all the letsencrypt certs from the db that will expire within N days + // Fetch all the letsencrypt certs from the db that will expire within the configured threshold certificateModel .query() .where('is_deleted', 0) @@ -75,6 +76,7 @@ const internalCertificate = { Promise.resolve({ permission_visibility: 'all', }), + token: new tokenModel(), }, { id: certificate.id }, ) @@ -88,6 +90,7 @@ const internalCertificate = { return sequence; }) .then(() => { + logger.info('Completed SSL cert renew process'); internalCertificate.intervalProcessing = false; }) .catch((err) => {