Skip to content

Instantly share code, notes, and snippets.

Last active February 9, 2022 21:38
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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")


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