Skip to content

Instantly share code, notes, and snippets.

@karlstolley
Last active Feb 9, 2022
Embed
What would you like to do?
Command to generate SSL certificates for HTTPS; use with `http-server`
# ~/.zshrc or whatever your startup file is (.profile, .bashrc, etc.):
# https-server alias
alias https-server="http-server -S -C ~/Certs/localhost.crt -K ~/Certs/localhost.key -p 8443"
## NOTE: You will need to install `http-server` via npm by running:
#
# $ npm install -g http-server
#
#

Command to Generate Certs

Be sure to cd into ~/Certs first:

openssl req -x509 -out localhost.crt -keyout localhost.key \
  -newkey rsa:2048 -nodes -sha256 -days 1825 \
  -subj '/CN=localhost' -extensions EXT -config <( \
   printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")

See https://letsencrypt.org/docs/certificates-for-localhost/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment