Created
July 21, 2021 13:15
-
-
Save denvit/5c4688ddbaeeb77bcb785702349b03f9 to your computer and use it in GitHub Desktop.
Script for generating SSL certificate on MacOSX
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 | |
echo Enter domain: | |
read domain | |
openssl req \ | |
-newkey rsa:2048 \ | |
-x509 \ | |
-nodes \ | |
-keyout $domain.key \ | |
-new \ | |
-out $domain.crt \ | |
-subj /CN=$domain \ | |
-reqexts SAN \ | |
-extensions SAN \ | |
-config <(cat /System/Library/OpenSSL/openssl.cnf \ | |
<(printf '[SAN]\nsubjectAltName=DNS:'${domain}'')) \ | |
-sha256 \ | |
-days 3650 | |
mv $domain.key /usr/local/etc/openssl/private | |
mv $domain.crt /usr/local/etc/openssl/certs | |
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain /usr/local/etc/openssl/certs/$domain.crt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment