mkimapdcert 996 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #! /bin/sh
  2. #
  3. # mkimapdcert,v 1.1 2001/01/02 03:54:25 drobbins Exp
  4. #
  5. # Copyright 2000 Double Precision, Inc. See COPYING for
  6. # distribution information.
  7. #
  8. # This is a short script to quickly generate a self-signed X.509 key for
  9. # IMAP over SSL. Normally this script would get called by an automatic
  10. # package installation routine.
  11. test -x /usr/bin/openssl || exit 0
  12. prefix="/usr"
  13. pemfile="/etc/courier-imap/imapd.pem"
  14. randfile="/etc/courier-imap/imapd.rand"
  15. if test -f $pemfile
  16. then
  17. echo "$pemfile already exists."
  18. exit 1
  19. fi
  20. cp /dev/null $pemfile
  21. chmod 600 $pemfile
  22. chown root $pemfile
  23. cleanup() {
  24. rm -f $pemfile
  25. rm -f $randfile
  26. exit 1
  27. }
  28. dd if=/dev/urandom of=$randfile count=1 2>/dev/null
  29. /usr/bin/openssl req -new -x509 -days 365 -nodes \
  30. -config /etc/courier-imap/imapd.cnf -out $pemfile -keyout $pemfile || cleanup
  31. /usr/bin/openssl gendh -rand $randfile 512 >> $pemfile || cleanup
  32. /usr/bin/openssl x509 -subject -dates -fingerprint -noout -in $pemfile || cleanup
  33. rm -f $randfile