@samitouri / QOSami-HFS / commits / 52f54108

fix: uncaught exception in case https certificate issues "key values mismatch"

Massimo Melina committed May 26, 2024 at 07:19 UTC 52f5410862b97a86a240cf38e00f4bd891585ac8
1 file changed +4 -3
src/listen.ts
+4 -3
@@ -122,9 +122,10 @@ const considerHttps = debounceAsync(async () => {
122 return httpsSrv.error = "cannot read " + namesForOutput[cantRead]
123 }
124 }
125 - catch(e) {
126 - httpsSrv!.error = "bad private key or certificate"
127 - console.log("failed to create https server: check your private key and certificate", String(e))
125 + catch(e: any) {
126 + httpsSrv ||= Object.assign(https.createServer({}), { name: 'https' }) // a dummy container, in case creation failed because of certificate errors
127 + httpsSrv.error = "bad private key or certificate"
128 + console.error("failed to create https server: check your private key and certificate", e.message)
129 return
130 }
131 port = await startServer(httpsSrv, { port, host: listenInterface.get() })