openssl-ssl-certificate.sh 804 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/sh -e
  2. CERT=/etc/openssl/certs/apache.pem
  3. export RANDFILE=/dev/random
  4. if [ "$1" != "--force" -a -f $CERT ]; then
  5. echo "$CERT exists! Use \"$0 --force.\""
  6. exit 0
  7. fi
  8. if [ "$1" == "--force" ]; then
  9. shift
  10. fi
  11. echo
  12. echo creating selfsingned certificate
  13. echo "replace it with one signed by a certification authority (CA)"
  14. echo
  15. echo enter your ServerName at the Common Name prompt
  16. echo
  17. echo If you want your certificate to expire after x days call this programm
  18. echo with "-days x". Default: 30 days
  19. # use special .cnf, because with normal one no valid selfsigned
  20. # certificate is created
  21. openssl req $@ -config /etc/openssl/openssl.cnf \
  22. -new -x509 -nodes -out $CERT -keyout $CERT
  23. chmod 600 $CERT
  24. ln -sf $CERT \
  25. /etc/openssl/certs/`/usr/bin/openssl x509 -noout -hash < $CERT`.0