fix(autsni): Fixed garbage collection for unfinished certificates

This commit is contained in:
Andris Reinman 2024-05-02 13:51:14 +03:00
parent 7ee5d06520
commit 5bf6c86542
No known key found for this signature in database
GPG key ID: DC6C83F4D584D364

View file

@ -21,7 +21,7 @@ const generateKeyPair = promisify(crypto.generateKeyPair);
const CERT_RENEW_TTL = 30 * 24 * 3600 * 1000;
const CERT_RENEW_DELAY = 24 * 3600 * 1000;
// delete uninitialized certificates after 1 day
const CERT_GARBAGE_TTL = 24 * 2300 * 1000;
const CERT_GARBAGE_TTL = 24 * 3600 * 1000;
class CertHandler {
constructor(options) {
@ -117,7 +117,7 @@ class CertHandler {
let r = await this.database.collection('certs').deleteMany({
acme: true,
updated: {
$lt: new Date(Date.now() + CERT_GARBAGE_TTL)
$lt: new Date(Date.now() - CERT_GARBAGE_TTL)
},
$or: [{ expires: { $exists: false } }, { expires: { $lt: new Date() } }],
autogenerated: true