1 | #!/opt/local/bin/zsh |
---|
2 | |
---|
3 | setopt X_Trace; |
---|
4 | |
---|
5 | # Generates a self-signed certificate. |
---|
6 | # Edit dovecot-openssl.cnf before running this. |
---|
7 | |
---|
8 | OPENSSL=${OPENSSL-openssl} |
---|
9 | SSLDIR=${SSLDIR-/opt/local/etc/ssl} |
---|
10 | OPENSSLCONFIG=${OPENSSLCONFIG-dovecot-openssl.cnf} |
---|
11 | |
---|
12 | CERTFILE=$SSLDIR/certs/dovecot.pem |
---|
13 | KEYFILE=$SSLDIR/private/dovecot.pem |
---|
14 | |
---|
15 | if [ ! -d $SSLDIR/certs ]; then |
---|
16 | echo "$SSLDIR/certs directory doesn't exist" |
---|
17 | fi |
---|
18 | |
---|
19 | if [ ! -d $SSLDIR/private ]; then |
---|
20 | echo "$SSLDIR/private directory doesn't exist" |
---|
21 | fi |
---|
22 | |
---|
23 | if [ -f $CERTFILE ]; then |
---|
24 | echo "$CERTFILE already exists, won't overwrite" |
---|
25 | exit 1 |
---|
26 | fi |
---|
27 | |
---|
28 | if [ -f $KEYFILE ]; then |
---|
29 | echo "$KEYFILE already exists, won't overwrite" |
---|
30 | exit 1 |
---|
31 | fi |
---|
32 | |
---|
33 | $OPENSSL req -new -x509 -nodes -config $OPENSSLCONFIG -out $CERTFILE -keyout $KEYFILE -days 3650 || exit 2 |
---|
34 | chmod 0600 $KEYFILE |
---|
35 | echo |
---|
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 : |
---|