meesteridle

mk-self-ssl

Jun 19th, 2015
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.73 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # usage: mk-self-ssl <foo> [n days]
  4. # first variable, file name, is required
  5. # second variable, number of days, is optional
  6.  
  7. umask 277
  8.  
  9. OPENSSL=/usr/bin/openssl
  10.  
  11. if [ -z $1 ]; then
  12.  
  13. echo -e "\nMissing file name\n"
  14.  
  15. elif [ -z $2 ]; then
  16.  
  17. # Generate private key and certificate signing request
  18. $OPENSSL genrsa -out $1.key 2048
  19. $OPENSSL req -new -key $1.key -out $1.csr
  20. # Generate SSL certificate
  21. $OPENSSL x509 -req -days 365 -in $1.csr -signkey $1.key -out $1.crt
  22.  
  23. else
  24.  
  25. # Generate private key and certificate signing request
  26. $OPENSSL genrsa -out $1.key 2048
  27. $OPENSSL req -new -key $1.key -out $1.csr
  28. # Generate SSL certificate
  29. $OPENSSL x509 -req -days $2 -in $1.csr -signkey $1.key -out $1.crt
  30.  
  31. fi
Advertisement
Add Comment
Please, Sign In to add comment