Command line tool to create self signed SSL certificate
Based on the following amazing GIST.
This only works on MAC!
Requires Node version 8 or higher
In the folder of your project use the NPM executer:
This will create a certificate for the domain: FOLDER_NAME.test and any subdomain.
npx create-ssl-certificate --hostname myproject
This will create a certificate for the domain: myproject.test and any subdomain.
npx create-ssl-certificate --hostname myproject --domain localhost
This will create a certificate for the domain: myproject.test and any subdomain. Only
localhost are recommended because they are specifically reserved as special-use domains.
Route to localhost
You choose either 1. or 2.
1. Simple setup
This setup only works for the specific hostname and no subdomains. Add the following, where you replace hostname and top level domin name to your own configuration:
2. Universal setup
brew install dnsmasq
To make it start when your mac boots up:
brew services start dnsmasq
To route all top level domain lookups to localhost you will have to run these commands.
test in both echo commands if you chose a different top level domain.
mkdir -pv $(brew --prefix)/etcsudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemonssudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plistsudo mkdir -pv /etc/resolverecho "address=/.test/127.0.0.1" | sudo tee -a $(brew --prefix)/etc/dnsmasq.confecho "nameserver 127.0.0.1" | sudo tee /etc/resolver/test
You usually have to restart your computer for this to take proper effect.