Last active
November 27, 2018 15:30
-
-
Save zmax/1534771b9f52b1365ded354bb3beff37 to your computer and use it in GitHub Desktop.
Generating a self-signed cert on macOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| HOST=${1} | |
| mkdir -p ~/.ssl | |
| # generate cert and key | |
| openssl req -newkey rsa:2048 -x509 -nodes -keyout ~/.ssl/$HOST.key -new -out ~/.ssl/$HOST.crt -subj /CN=$HOST -reqexts SAN -extensions SAN -config <(cat /System/Library/OpenSSL/openssl.cnf <(printf "[SAN]\nsubjectAltName=DNS:${HOST}")) -sha256 -days 3650 | |
| # add to keychains | |
| sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/.ssl/${HOST}.crt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment