fix: disabling acme_renew was not effective
Massimo Melina committed
Oct 21, 2023 at 02:52 UTC
0e71627f492c2beb548f23be6c54418666110ff5
1 file changed
+5
-5
src/acme.ts
+5
-5
@@ -91,14 +91,14 @@ export const makeCert = debounceAsync(async (domain: string, email?: string) =>
91
privateKey.set(KEY_FILE)
92
}, 0)
93
94
-defineConfig('acme_renew', false) // handle config changes
94
+const acmeDomain = defineConfig('acme_domain', '')
95
+const acmeEmail = defineConfig('acme_email', '')
96
+const acmeRenew = defineConfig('acme_renew', false) // handle config changes
97
events.once('https ready', () => repeat(HOUR, renewCert))
98
97
-export const acme_domain = defineConfig<string>('acme_domain', '')
98
-export const acme_email = defineConfig<string>('acme_email', '')
99
-
99
// checks if the cert is near expiration date, and if so renews it
100
const renewCert = debounceAsync(async () => {
101
+ if (!acmeRenew.get()) return
102
const cert = getCertObject()
103
if (!cert) return
104
const now = new Date()
@@ -106,7 +106,7 @@ const renewCert = debounceAsync(async () => {
106
// not expiring in a month
107
if (now > new Date(cert.validFrom) && now < validTo && validTo.getTime() - now.getTime() >= 30 * DAY)
108
return console.log("certificate still good")
109
- await makeCert(acme_domain.get(), acme_email.get())
109
+ await makeCert(acmeDomain.get(), acmeEmail.get())
110
.catch(e => console.log("error renewing certificate: ", String(e)))
111
}, 0, { retain: DAY, retainFailure: HOUR })
112