Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTPS: Adding Ability to Send Passphrase to createServer #655

Merged
merged 2 commits into from
Jun 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions bin/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,12 @@ const getHelp = () => chalk`
--no-etag Send \`Last-Modified\` header instead of \`ETag\`

-S, --symlinks Resolve symlinks instead of showing 404 errors

--ssl-cert Optional path to an SSL/TLS certificate to serve with HTTPS

--ssl-key Optional path to the SSL/TLS certificate\'s private key

--ssl-cert Optional path to an SSL/TLS certificate to serve with HTTPS

--ssl-key Optional path to the SSL/TLS certificate\'s private key
--ssl-pass Optional path to the SSL/TLS certificate\'s passphrase

--no-port-switching Do not open a port other than the one specified when it\'s taken.

Expand Down Expand Up @@ -200,10 +202,13 @@ const startEndpoint = (endpoint, config, args, previous) => {
return handler(request, response, config);
};

const sslPass = args['--ssl-pass'];

const server = httpMode === 'https'
? https.createServer({
key: fs.readFileSync(args['--ssl-key']),
cert: fs.readFileSync(args['--ssl-cert'])
cert: fs.readFileSync(args['--ssl-cert']),
passphrase: sslPass ? fs.readFileSync(sslPass) : ''
}, serverHandler)
: http.createServer(serverHandler);

Expand Down Expand Up @@ -379,6 +384,7 @@ const loadConfig = async (cwd, entry, args) => {
'--no-port-switching': Boolean,
'--ssl-cert': String,
'--ssl-key': String,
'--ssl-pass': String,
'-h': '--help',
'-v': '--version',
'-l': '--listen',
Expand Down