Created
April 9, 2014 11:21
-
-
Save chorn/10256916 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env bash | |
newssl() { | |
case "$1" in | |
rsa|-rsa|--rsa|-r) openssl genrsa -out key.pem 1024 >&/dev/null ;; | |
dsa|-dsa|--dsa|-d) openssl dsaparam -noout -out key.pem -genkey 1024 >&/dev/null ;; | |
ec|-ec|--ec|-e) openssl ecparam -out key.pem -name sect571k1 -genkey >&/dev/null ;; | |
*) echo "newssl <rsa|dsa|ec> <hostname>" ; return ;; | |
esac | |
openssl req -new -x509 -days 3650 -subj "/C=US/ST=New York/L=Rochester/CN=$2" -key key.pem -out "$2.pem" >&/dev/null | |
openssl x509 -in "$2.pem" -text >&/dev/null | |
cat key.pem >> "$2.pem" && rm key.pem >&/dev/null | |
} | |
# To create a self-signed my.hostname.com.pem using dsa: | |
# source newssl.sh | |
# newssl dsa my.hostname.com | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment