From 04e449c546842d8c5f33466370d941e6b40e2168 Mon Sep 17 00:00:00 2001 From: Asher Date: Mon, 24 Feb 2020 14:55:17 -0600 Subject: [PATCH] Require cert-key with cert Fixes #1312. --- src/node/entry.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/node/entry.ts b/src/node/entry.ts index f13c847e..33419243 100644 --- a/src/node/entry.ts +++ b/src/node/entry.ts @@ -37,10 +37,13 @@ const main = async (args: Args): Promise => { port: typeof args.port !== "undefined" ? args.port : process.env.PORT !== "" ? process.env.PORT : 8080, socket: args.socket, } + if (!options.cert && args.cert) { const { cert, certKey } = await generateCertificate() options.cert = cert options.certKey = certKey + } else if (args.cert && !args["cert-key"]) { + throw new Error("--cert-key is missing") } const httpServer = new HttpServer(options) @@ -70,7 +73,7 @@ const main = async (args: Args): Promise => { if (httpServer.protocol === "https") { logger.info( typeof args.cert === "string" - ? ` - Using provided certificate${args["cert-key"] ? " and key" : ""} for HTTPS` + ? ` - Using provided certificate and key for HTTPS` : ` - Using generated certificate and key for HTTPS`, ) } else {