From 1b659a5574170a9183827c3e26df1336c6b8886c Mon Sep 17 00:00:00 2001 From: Nicholas Pepper Date: Tue, 12 May 2020 03:36:46 +0000 Subject: [PATCH] Modified letsencrypt support to add domain name checking in addition to hostname checking. Added necessary tests and renamed original manual ssl test to a name that supports adding the other SSL tests. --- target/start-mailserver.sh | 64 ++++++++------ .../config/letsencrypt/my-domain.com/cert.pem | 30 +++++++ .../letsencrypt/my-domain.com/chain.pem | 27 ++++++ .../letsencrypt/my-domain.com/fullchain.pem | 57 +++++++++++++ test/config/letsencrypt/my-domain.com/key.pem | 28 +++++++ test/mail_pop3.bats | 21 ----- test/mail_ssl_letsencrypt.bats | 84 +++++++++++++++++++ ...l_manual_ssl.bats => mail_ssl_manual.bats} | 0 8 files changed, 265 insertions(+), 46 deletions(-) create mode 100644 test/config/letsencrypt/my-domain.com/cert.pem create mode 100644 test/config/letsencrypt/my-domain.com/chain.pem create mode 100644 test/config/letsencrypt/my-domain.com/fullchain.pem create mode 100644 test/config/letsencrypt/my-domain.com/key.pem create mode 100644 test/mail_ssl_letsencrypt.bats rename test/{mail_manual_ssl.bats => mail_ssl_manual.bats} (100%) diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index 8178844d..43b71c9e 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -1043,34 +1043,48 @@ function _setup_ssl() { # SSL certificate Configuration case $SSL_TYPE in "letsencrypt" ) - # letsencrypt folders and files mounted in /etc/letsencrypt - if [ -e "/etc/letsencrypt/live/$HOSTNAME/fullchain.pem" ]; then - KEY="" - if [ -e "/etc/letsencrypt/live/$HOSTNAME/privkey.pem" ]; then - KEY="privkey" - elif [ -e "/etc/letsencrypt/live/$HOSTNAME/key.pem" ]; then - KEY="key" - else - notify 'err' "Cannot access '/etc/letsencrypt/live/"$HOSTNAME"/privkey.pem' nor 'key.pem'" - fi - if [ -n "$KEY" ]; then - notify 'inf' "Adding $HOSTNAME SSL certificate" + notify 'inf' "Configuring SSL using 'letsecnrypt'" + # letsencrypt folders and files mounted in /etc/letsencrypt + local LETSENCRYPT_DOMAIN="" + local LETSENCRYPT_KEY="" - # Postfix configuration - sed -i -r 's~smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem~smtpd_tls_cert_file=/etc/letsencrypt/live/'$HOSTNAME'/fullchain.pem~g' /etc/postfix/main.cf - sed -i -r 's~smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key~smtpd_tls_key_file=/etc/letsencrypt/live/'$HOSTNAME'/'"$KEY"'\.pem~g' /etc/postfix/main.cf - - # Dovecot configuration - sed -i -e 's~ssl_cert =