gen-cert.sh 496 B

12345678910111213141516171819202122
  1. #!/bin/sh
  2. #
  3. # Script for generating key-cert pairs
  4. #
  5. if [[ $# -ne 2 ]]; then
  6. echo "Usage: ${0##*/} KEY CERT"
  7. exit
  8. fi
  9. KEY=$1
  10. CERT=$2
  11. PSWD=test
  12. read -s -p "Enter Password: " $PSWD
  13. openssl genrsa -des3 -passout pass:$PSWD -out $KEY.key 1024
  14. openssl req -new -key $KEY.key -out $KEY.csr -passin pass:$PSWD
  15. cp $KEY.key $KEY.key.org
  16. openssl rsa -in $KEY.key.org -out $KEY.key -passin pass:$PSWD
  17. openssl x509 -req -days 365 -in $KEY.csr -signkey $KEY.key -out $CERT.crt
  18. rm $KEY.key.org $KEY.csr