From 06d1f43f9eb5e58a9ad615951b506208e4242da0 Mon Sep 17 00:00:00 2001 From: kiranghule Date: Sat, 24 Mar 2018 10:08:27 +0530 Subject: [PATCH 1/2] feat: added support for passphrase to decrypt private key when enabling ssl --- README.md | 2 ++ bin/http-server | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 74d57a6c..d22ae5ce 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,8 @@ This will install `http-server` globally so that it may be run from the command `-K` or `--key` Path to ssl key file (default: key.pem). + `-P` or `--passphrase` Pass phrase to decrypt the key (optional). + `-r` or `--robots` Provide a /robots.txt (whose content defaults to 'User-agent: *\nDisallow: /') `-h` or `--help` Print this list and exit. diff --git a/bin/http-server b/bin/http-server index 926e0dd7..d938ca9c 100755 --- a/bin/http-server +++ b/bin/http-server @@ -37,6 +37,7 @@ if (argv.h || argv.help) { ' -S --ssl Enable https.', ' -C --cert Path to ssl cert file (default: cert.pem).', ' -K --key Path to ssl key file (default: key.pem).', + ' -P --passphrase Pass phrase to decrypt the key (optional)', '', ' -r --robots Respond to /robots.txt [User-agent: *\\nDisallow: /]', ' --no-dotfiles Do not show dotfiles', @@ -118,6 +119,9 @@ function listen(port) { cert: argv.C || argv.cert || 'cert.pem', key: argv.K || argv.key || 'key.pem' }; + if (argv.P || argv.passphrase) { + options.https['passphrase'] = argv.P || argv.passphrase; + } } var server = httpServer.createServer(options); From 267351e62e62da2b4ca8545f9c45c074c8a23a97 Mon Sep 17 00:00:00 2001 From: kiranghule Date: Sat, 24 Mar 2018 10:18:20 +0530 Subject: [PATCH 2/2] code style formatting updated --- bin/http-server | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/http-server b/bin/http-server index d938ca9c..f9d49300 100755 --- a/bin/http-server +++ b/bin/http-server @@ -120,7 +120,7 @@ function listen(port) { key: argv.K || argv.key || 'key.pem' }; if (argv.P || argv.passphrase) { - options.https['passphrase'] = argv.P || argv.passphrase; + options.https.passphrase = argv.P || argv.passphrase; } }