howto/SetupDovecot: Make_Dovecot_Certificates.command

File Make_Dovecot_Certificates.command, 992 bytes (added by martin.osx@…, 16 years ago)

Z-Shell script to create dovecot certificate

Line 
1#!/opt/local/bin/zsh
2
3setopt X_Trace;
4
5# Generates a self-signed certificate.
6# Edit dovecot-openssl.cnf before running this.
7
8OPENSSL=${OPENSSL-openssl}
9SSLDIR=${SSLDIR-/opt/local/etc/ssl}
10OPENSSLCONFIG=${OPENSSLCONFIG-dovecot-openssl.cnf}
11
12CERTFILE=$SSLDIR/certs/dovecot.pem
13KEYFILE=$SSLDIR/private/dovecot.pem
14
15if [ ! -d $SSLDIR/certs ]; then
16  echo "$SSLDIR/certs directory doesn't exist"
17fi
18
19if [ ! -d $SSLDIR/private ]; then
20  echo "$SSLDIR/private directory doesn't exist"
21fi
22
23if [ -f $CERTFILE ]; then
24  echo "$CERTFILE already exists, won't overwrite"
25  exit 1
26fi
27
28if [ -f $KEYFILE ]; then
29  echo "$KEYFILE already exists, won't overwrite"
30  exit 1
31fi
32
33$OPENSSL req -new -x509 -nodes -config $OPENSSLCONFIG -out $CERTFILE -keyout $KEYFILE -days 3650 || exit 2
34chmod 0600 $KEYFILE
35echo 
36$OPENSSL x509 -subject -fingerprint -noout -in $CERTFILE || exit 2
37
38#vim: set nowrap tabstop=8 shiftwidth=4 softtabstop=4 expandtab :
39#vim: set textwidth=0 filetype=zsh foldmethod=marker nospell :