From 79139fa98079bf40260f47b1de3ce03c4f7a0137 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Mon, 25 Jul 2022 03:05:38 -0400 Subject: [PATCH] *Only load ssl in setup if it is the bootup process --- src/relay.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/relay.ts b/src/relay.ts index 863052b..9ab5915 100644 --- a/src/relay.ts +++ b/src/relay.ts @@ -56,7 +56,7 @@ export async function start() { let httpServer = http.createServer(app); - cron.schedule("0 * * * *", setupSSl); + cron.schedule("0 * * * *", setupSSl.bind(null, false)); await new Promise((resolve) => { httpServer.listen(80, "0.0.0.0", function () { @@ -84,10 +84,10 @@ export async function start() { }); }); - await setupSSl(); + await setupSSl(true); } -async function setupSSl() { +async function setupSSl(bootup: boolean) { let sslCert = await getSslCert(); let sslKey = await getSslKey(); let certInfo; @@ -125,8 +125,10 @@ async function setupSSl() { } if (dateValid && domainValid) { - sslCtx = tls.createSecureContext(sslParams); - log.info(`Loaded SSL Certificate for ${configDomain}`); + if (bootup) { + sslCtx = tls.createSecureContext(sslParams); + log.info(`Loaded SSL Certificate for ${configDomain}`); + } return; }