Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. # Constants
  3. RED='\033[0;31m'
  4. GR='\033[0;32m'
  5. NC='\033[0m' # No Color
  6. # Hello
  7. echo "Hello, ${RED}"$USER"${NC}. This script will generate CSR for SSL Cert"
  8.  
  9. # CommonName
  10. echo -n "${GR}Enter your domain CommonName [ENTER]: ${NC}"
  11. read domain
  12.  
  13. #Required
  14. commonname=$domain
  15.  
  16. #Change to your company details
  17. country=
  18. state="
  19. locality=
  20. organization=
  21. organizationalunit=
  22. email=EMAIL
  23. #while read CERT_DATA; do echo "$CERT_DATA" ; done < cert_data #For future
  24.  
  25. #Optional
  26. password=
  27. # Confirm data
  28. echo "${GR}Please confirm data:${NC}"
  29. echo "${RED}Country Name= ${GR}$country${NC}"
  30. echo "${RED}State Name= ${GR}$state${NC}"
  31. echo "${RED}Locality Name= ${GR}$locality${NC}"
  32. echo "${RED}Organization Name= ${GR}$organization${NC}"
  33. echo "${RED}Email Address= ${GR}$email${NC}"
  34. echo "${RED}Common Name= ${GR}$domain${NC}"
  35.  
  36. echo -n "Start? (y/n) "
  37. read item
  38. case "$item" in
  39. y|Y);;
  40. n|N) exit 0;;
  41. *);;
  42. esac
  43.  
  44. if [ -z "$domain" ]
  45. then
  46. echo "Argument not present."
  47. echo "Useage $0 [common name]"
  48.  
  49. exit 99
  50. fi
  51.  
  52. #Create directory
  53. mkdir $domain
  54. #Create the request
  55. echo "Creating CSR"
  56. openssl req -days 365 -out $domain/$domain.csr -new -newkey rsa:2048 -nodes -keyout $domain/$domain.key \
  57. -subj "/C=$country/ST=$state/L=$locality/O=$organization/CN=$commonname/emailAddress=$email"
  58.  
  59. echo "---------------------------"
  60. echo "-----Below is your CSR-----"
  61. echo "---------------------------"
  62. echo
  63. cat $domain/$domain.csr
  64.  
  65. echo
  66. echo "---------------------------"
  67. echo "-----Below is your Key-----"
  68. echo "---------------------------"
  69. echo
  70. cat $domain/$domain.key
  71. echo
  72. echo "---------------------------"
  73. echo "-----Files locations-----"
  74. echo "---------------------------"
  75. echo "Your CSR file in directory: $domain/$domain.csr"
  76. echo "Your Key file in directory: $domain/$domain.key"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement