dovecot-cn (1:2.2.13~cn1) stable; urgency=medium
* Postavlja ssl = yes u 10-auth.conf
+ * Generira self-signed certifikat
-- Ivan Rako <Ivan.Rako@CARNet.hr> Tue, 09 May 2017 14:34:56 +0200
--- /dev/null
+usr/share/dovecot-cn
--- /dev/null
+mkcert.sh usr/share/dovecot-cn
's/^ssl = no/ssl = yes/g' \
/etc/dovecot/conf.d/10-ssl.conf || true
+if ! grep -q ^ssl_cert /etc/dovecot/conf.d/10-ssl.conf \
+ && ! grep -q ^ssl_key /etc/dovecot/conf.d/10-ssl.conf; then
+ cp_check_and_sed '#ssl_cert = </etc/dovecot/dovecot.pem' \
+ 's|#ssl_cert = </etc/dovecot/dovecot.pem|ssl_cert = </etc/dovecot/dovecot.pem|g' \
+ /etc/dovecot/conf.d/10-ssl.conf || true
+ cp_check_and_sed '#ssl_key = </etc/dovecot/private/dovecot.pem' \
+ 's|#ssl_key = </etc/dovecot/private/dovecot.pem|ssl_key = </etc/dovecot/private/dovecot.pem|g' \
+ /etc/dovecot/conf.d/10-ssl.conf || true
+
+ echo "CN: Generating certificate and key..."
+ /usr/share/dovecot-cn/mkcert.sh > /dev/null
+fi
+
+
+
# dodao ico, gasi stare SSL protokole
cp_check_and_sed '#ssl_protocols =' \
's/^#ssl_protocols.*/ssl_protocols = !SSLv2 !SSLv3/g' \
--- /dev/null
+#!/bin/sh
+
+# Generates a self-signed certificate.
+# Edit dovecot-openssl.cnf before running this.
+
+umask 077
+OPENSSL=${OPENSSL-openssl}
+SSLDIR=${SSLDIR-/etc/ssl}
+OPENSSLCONFIG=${OPENSSLCONFIG-dovecot-openssl.cnf}
+
+CERTDIR=/etc/dovecot
+KEYDIR=/etc/dovecot/private
+
+CERTFILE=$CERTDIR/dovecot.pem
+KEYFILE=$KEYDIR/dovecot.pem
+
+if [ ! -d $CERTDIR ]; then
+ echo "$SSLDIR/certs directory doesn't exist"
+ exit 1
+fi
+
+if [ ! -d $KEYDIR ]; then
+ echo "$SSLDIR/private directory doesn't exist"
+ exit 1
+fi
+
+if [ -f $CERTFILE ]; then
+ echo "$CERTFILE already exists, won't overwrite"
+ exit 1
+fi
+
+if [ -f $KEYFILE ]; then
+ echo "$KEYFILE already exists, won't overwrite"
+ exit 1
+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