summaryrefslogtreecommitdiffstats
path: root/main/dovecot/dovecot.post-install
blob: a7cccddfd8edd38fc68fad3c16ec74797b244b6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh

# based on  doc/mkcert.sh

# Generates a self-signed certificate.
# Edit dovecot-openssl.cnf before running this.

OPENSSL=${OPENSSL-openssl}
SSLDIR=${SSLDIR-/etc/ssl/dovecot}
OPENSSLCONFIG=${OPENSSLCONFIG-/etc/dovecot/dovecot-openssl.cnf}

CERTDIR=$SSLDIR
KEYDIR=$SSLDIR

CERTFILE=$CERTDIR/server.pem
KEYFILE=$KEYDIR/server.key

if [ -e "$CERTFILE" ]; then
	echo "Keeiping existing $CERTFILE"
	exit 0
fi

if [ -e "$KEYFILE" ]; then
	echo "Keeiping existing $KEYFILE"
	exit 0
fi

$OPENSSL req -new -x509 -nodes -config $OPENSSLCONFIG -out $CERTFILE -keyout $KEYFILE -days 365 || exit 2
chmod 0600 $KEYFILE
echo 
$OPENSSL x509 -subject -fingerprint -noout -in $CERTFILE || exit 2