Last active
February 17, 2020 23:24
-
-
Save Umkus/6feef126aee247ae3d1734d68182df22 to your computer and use it in GitHub Desktop.
Self-signed wildcard certificate generator
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 | |
if [ $# -eq 0 ] | |
then | |
echo Self-signed wildcard certificate generator | |
echo | |
echo -n Usage: $0 example.com | |
echo | |
exit; | |
fi | |
cat > openssl.cnf <<-EOF | |
[req] | |
distinguished_name = req_distinguished_name | |
x509_extensions = v3_req | |
prompt = no | |
[req_distinguished_name] | |
CN = *.$1 | |
[v3_req] | |
keyUsage = nonRepudiation, digitalSignature, keyEncipherment | |
extendedKeyUsage = serverAuth | |
subjectAltName = @alt_names | |
[alt_names] | |
DNS.1 = *.$1 | |
DNS.2 = $1 | |
EOF | |
openssl req \ | |
-new \ | |
-newkey rsa:2048 \ | |
-sha1 \ | |
-days 3650 \ | |
-nodes \ | |
-x509 \ | |
-keyout $1.key \ | |
-out $1.crt \ | |
-extensions v3_req \ | |
-config openssl.cnf | |
rm openssl.cnf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment