Skip to content

Commit 04e449c

Browse files
committed
Require cert-key with cert
Fixes coder#1312.
1 parent c147711 commit 04e449c

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/node/entry.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@ const main = async (args: Args): Promise<void> => {
3737
port: typeof args.port !== "undefined" ? args.port : process.env.PORT !== "" ? process.env.PORT : 8080,
3838
socket: args.socket,
3939
}
40+
4041
if (!options.cert && args.cert) {
4142
const { cert, certKey } = await generateCertificate()
4243
options.cert = cert
4344
options.certKey = certKey
45+
} else if (args.cert && !args["cert-key"]) {
46+
throw new Error("--cert-key is missing")
4447
}
4548

4649
const httpServer = new HttpServer(options)
@@ -70,7 +73,7 @@ const main = async (args: Args): Promise<void> => {
7073
if (httpServer.protocol === "https") {
7174
logger.info(
7275
typeof args.cert === "string"
73-
? ` - Using provided certificate${args["cert-key"] ? " and key" : ""} for HTTPS`
76+
? ` - Using provided certificate and key for HTTPS`
7477
: ` - Using generated certificate and key for HTTPS`,
7578
)
7679
} else {

0 commit comments

Comments
 (0)