Skip to content

Instantly share code, notes, and snippets.

@zackify
Last active October 14, 2019 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zackify/3deee3d6af7268f7edfef542ae6fab87 to your computer and use it in GitHub Desktop.
Save zackify/3deee3d6af7268f7edfef542ae6fab87 to your computer and use it in GitHub Desktop.
Create cert for webpack in one command, mac
"create-cert": "bash -c \"openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout config/server.key -out config/server.crt -subj \"/C=US/ST=Nevada/L=test/O=test/OU=Software/CN=localhost\" -extensions san -config <(echo '[req]'; echo 'distinguished_name=req'; echo '[san]'; echo 'subjectAltName=DNS:localhost,IP:127.0.0.1') && sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain config/server.crt\"",

@tarrall
Copy link

tarrall commented Oct 14, 2019

For MacOS 10.15 Catalina, you may need that -config stanza to look like:

[...] -config <(echo '[req]'; echo 'distinguished_name=req'; echo '[san]'; echo 'subjectAltName=DNS:localhost,IP:127.0.0.1'; echo 'extendedKeyUsage=serverAuth')

... because Apple added new requirements for SSL certs: https://support.apple.com/en-us/HT210176

@zackify
Copy link
Author

zackify commented Oct 14, 2019

Thanks! How did you even find this gist though? Haha

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