Skip to content

Instantly share code, notes, and snippets.

@lukespragg
Created May 13, 2014 21:20
Show Gist options
  • Select an option

  • Save lukespragg/f70f6cec38d4601abccb to your computer and use it in GitHub Desktop.

Select an option

Save lukespragg/f70f6cec38d4601abccb to your computer and use it in GitHub Desktop.
#!/bin/bash
clear
prompt="Pick select a task: "
options=("Generate Certificate Signing Request" "Generate Chained Certificate" "Decrypt Private Key")
PS3="$prompt "
select opt in "${options[@]}" "Quit"; do
case "$REPLY" in
1 ) echo "You picked \"$opt\""
read -p "Domain name to use: " domain
while [[ -z "$domain" || "$domain" == "" ]]; do
echo "You must enter a valid domain name!"
read -p "Domain name to use: " domain
done
read -p "RSA key size/length [4096]: " keysize
keysize=${keysize:-4096}
read -p "Length in days [1095]: " days
days=${days:-1095}
openssl req -out ${domain}.org.csr -new -nodes -newkey rsa:${keysize} -sha256 -days ${days} -keyout ${domain}.key
;;
2 ) echo "You picked \"$opt\""
read -p "Domain name to use: " domain
while [[ -z "$domain" || "$domain" == "" ]]; do
echo "You must enter a valid domain name!"
read -p "Domain name to use: " domain
done
read -p "Class 1 or class 2 [2]:" class
class=${class:-2}
wget -O startssl/ca.pem http://www.startssl.com/certs/ca.pem
wget -O startssl/sub.class1.server.ca.pem http://www.startssl.com/certs/sub.class1.server.ca.pem
wget -O startssl/sub.class2.server.ca.pem http://www.startssl.com/certs/sub.class2.server.ca.pem
cat ${domain}.crt sub.${class}.server.ca.pem > ${domain}_chained.crt
;;
3 ) echo "You picked \"$opt\""
read -p "Domain name to use: " domain
while [[ -z "$domain" || "$domain" == "" ]]; do
echo "You must enter a valid domain name!"
read -p "Domain name to use: " domain
done
openssl rsa -in ${domain}_encrypted.key -out ${domain}.key
;;
$(( ${#options[@]}+1 )) ) echo "Goodbye!"; break;;
*) echo "Invalid option. Try another one."; continue;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment