eventlog: add event for certificate cleanup
This commit is contained in:
@@ -657,13 +657,17 @@ async function renewCerts(options, auditSource, progressCallback) {
|
||||
}
|
||||
}
|
||||
|
||||
async function cleanupCerts() {
|
||||
async function cleanupCerts(auditSource) {
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
|
||||
const filenames = await fs.promises.readdir(paths.NGINX_CERT_DIR);
|
||||
const certFilenames = filenames.filter(f => f.endsWith('.cert'));
|
||||
const now = new Date();
|
||||
|
||||
debug('cleanupCerts: start');
|
||||
|
||||
const fqdns = [];
|
||||
|
||||
for (const certFilename of certFilenames) {
|
||||
const certFilePath = path.join(paths.NGINX_CERT_DIR, certFilename);
|
||||
const notAfter = getExpiryDate(certFilePath);
|
||||
@@ -681,9 +685,13 @@ async function cleanupCerts() {
|
||||
await blobs.del(`${blobs.CERT_PREFIX}-${fqdn}.key`);
|
||||
await blobs.del(`${blobs.CERT_PREFIX}-${fqdn}.cert`);
|
||||
await blobs.del(`${blobs.CERT_PREFIX}-${fqdn}.csr`);
|
||||
|
||||
fqdns.push(fqdn);
|
||||
}
|
||||
}
|
||||
|
||||
if (fqdns.length) await safe(eventlog.add(eventlog.ACTION_CERTIFICATE_CLEANUP, auditSource, { domains: fqdns }));
|
||||
|
||||
debug('cleanupCerts: done');
|
||||
}
|
||||
|
||||
@@ -693,7 +701,7 @@ async function checkCerts(options, auditSource, progressCallback) {
|
||||
assert.strictEqual(typeof progressCallback, 'function');
|
||||
|
||||
await renewCerts(options, auditSource, progressCallback);
|
||||
await cleanupCerts();
|
||||
await cleanupCerts(auditSource);
|
||||
}
|
||||
|
||||
function removeAppConfigs() {
|
||||
|
||||
Reference in New Issue
Block a user