Last active
August 29, 2015 14:04
-
-
Save m13253/fe76237a5dd249630033 to your computer and use it in GitHub Desktop.
Generate a self-signed SSL certificate for web server
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 | |
| set -e | |
| outpemfile="${1:-cert.pem}" | |
| tmpprefix="/tmp/gensslcert-$$" | |
| openssl genrsa -des3 -out "$tmpprefix.key" 2048 | |
| openssl req -new -key "$tmpprefix.key" -out "$tmpprefix.csr" | |
| openssl rsa -in "$tmpprefix.key" -out "$outpemfile" | |
| rm -f "$tmpprefix.key" | |
| openssl x509 -req -days 365 -in "$tmpprefix.csr" -signkey "$outpemfile" -out "$tmpprefix.crt" | |
| cat "$tmpprefix.crt" >> "$outpemfile" | |
| set +e | |
| chmod 600 "$outpemfile" | |
| rm -f "$tmpprefix.crt" "$tmpprefix.csr" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment