Archived
1
0

Require cert-key with cert

Fixes #1312.
This commit is contained in:
Asher 2020-02-24 14:55:17 -06:00
parent c147711ade
commit 04e449c546
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A

View File

@ -37,10 +37,13 @@ const main = async (args: Args): Promise<void> => {
port: typeof args.port !== "undefined" ? args.port : process.env.PORT !== "" ? process.env.PORT : 8080, port: typeof args.port !== "undefined" ? args.port : process.env.PORT !== "" ? process.env.PORT : 8080,
socket: args.socket, socket: args.socket,
} }
if (!options.cert && args.cert) { if (!options.cert && args.cert) {
const { cert, certKey } = await generateCertificate() const { cert, certKey } = await generateCertificate()
options.cert = cert options.cert = cert
options.certKey = certKey options.certKey = certKey
} else if (args.cert && !args["cert-key"]) {
throw new Error("--cert-key is missing")
} }
const httpServer = new HttpServer(options) const httpServer = new HttpServer(options)
@ -70,7 +73,7 @@ const main = async (args: Args): Promise<void> => {
if (httpServer.protocol === "https") { if (httpServer.protocol === "https") {
logger.info( logger.info(
typeof args.cert === "string" 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`, : ` - Using generated certificate and key for HTTPS`,
) )
} else { } else {