Skip to content

Commit e3f1e84

Browse files
HTTPS: Adding Ability to Send Passphrase to createServer (#655)
1 parent d941baa commit e3f1e84

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

bin/serve.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,12 @@ const getHelp = () => chalk`
9494
--no-etag Send \`Last-Modified\` header instead of \`ETag\`
9595
9696
-S, --symlinks Resolve symlinks instead of showing 404 errors
97+
98+
--ssl-cert Optional path to an SSL/TLS certificate to serve with HTTPS
99+
100+
--ssl-key Optional path to the SSL/TLS certificate\'s private key
97101
98-
--ssl-cert Optional path to an SSL/TLS certificate to serve with HTTPS
99-
100-
--ssl-key Optional path to the SSL/TLS certificate\'s private key
102+
--ssl-pass Optional path to the SSL/TLS certificate\'s passphrase
101103
102104
--no-port-switching Do not open a port other than the one specified when it\'s taken.
103105
@@ -200,10 +202,13 @@ const startEndpoint = (endpoint, config, args, previous) => {
200202
return handler(request, response, config);
201203
};
202204

205+
const sslPass = args['--ssl-pass'];
206+
203207
const server = httpMode === 'https'
204208
? https.createServer({
205209
key: fs.readFileSync(args['--ssl-key']),
206-
cert: fs.readFileSync(args['--ssl-cert'])
210+
cert: fs.readFileSync(args['--ssl-cert']),
211+
passphrase: sslPass ? fs.readFileSync(sslPass) : ''
207212
}, serverHandler)
208213
: http.createServer(serverHandler);
209214

@@ -379,6 +384,7 @@ const loadConfig = async (cwd, entry, args) => {
379384
'--no-port-switching': Boolean,
380385
'--ssl-cert': String,
381386
'--ssl-key': String,
387+
'--ssl-pass': String,
382388
'-h': '--help',
383389
'-v': '--version',
384390
'-l': '--listen',

0 commit comments

Comments
 (0)