diff --git a/postfix/defaults/main.yml b/postfix/defaults/main.yml index 416ef41d6a4d36aed31cb748e63855d3c08d89cb..bf3b04160adf364ecf54099deef7472105ad0777 100644 --- a/postfix/defaults/main.yml +++ b/postfix/defaults/main.yml @@ -6,8 +6,10 @@ postfix_virtual_domains: [] postfix_tls_cert: /etc/ssl/private/fullchain.pem postfix_tls_key: /etc/ssl/private/privkey.pem -postfix_tls_ciphers: "{{ tls_ciphers }}" -postfix_tls_protocols: '!SSLv2 !SSLv3' + +# possible values: modern, intermediate, old, previous +# see also: https://ssl-config.mozilla.org/ +postfix_tls_configuration: 'previous' postfix_prefer_lmtp: false postfix_enable_memcached: false diff --git a/postfix/tasks/main.yml b/postfix/tasks/main.yml index 089e0dd0f079b7ac2817b60af2e65d211ce4880d..3f19f4743a5cb4983f95ae36cda871870b2da13a 100644 --- a/postfix/tasks/main.yml +++ b/postfix/tasks/main.yml @@ -1,5 +1,12 @@ --- +- name: "include tls config vars (preset: {{ postfix_tls_configuration }})" + include_vars: + file: "tls-{{ postfix_tls_configuration }}.yml" + tags: + - postfix + - mail + - name: ensure all required postfix packages are installed apt: name: @@ -35,6 +42,20 @@ - postfix - mail +- name: ensure dh params are available + copy: + src: "{{ postfix_tls_dh_file }}" + dest: /etc/postfix/dh.pem + owner: root + group: root + mode: '0644' + when: postfix_tls_dh_file is string + notify: + - restart postfix + tags: + - postfix + - mail + - name: ensure memcached config is present template: src: memcached.conf.j2 diff --git a/postfix/templates/main.cf.j2 b/postfix/templates/main.cf.j2 index b891d06cabac1898f6f96f2a3234746c09aafa44..7034c73d8f87e0f42b0dbbeb218c0c65b96ee1c4 100644 --- a/postfix/templates/main.cf.j2 +++ b/postfix/templates/main.cf.j2 @@ -38,16 +38,32 @@ smtpd_relay_restrictions = defer_unauth_destination smtpd_use_tls = yes +smtpd_tls_security_level = may smtpd_tls_auth_only = yes smtpd_tls_cert_file = {{ postfix_tls_cert }} smtpd_tls_key_file = {{ postfix_tls_key }} -smtpd_tls_eecdh_grade = ultra -smtpd_tls_mandatory_ciphers = high -smtpd_tls_mandatory_protocols = {{ postfix_tls_protocols }} -smtpd_tls_protocols = {{ postfix_tls_protocols }} smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache -tls_high_cipherlist = {{ postfix_tls_ciphers }} +smtpd_tls_protocols = {{ postfix_tls_protocols }} +smtpd_tls_mandatory_protocols = {{ postfix_tls_protocols }} +{% if postfix_tls_mandatory_ciphers %} +smtpd_tls_mandatory_ciphers = {{ postfix_tls_mandatory_ciphers }} +{% endif %} +{% if postfix_tls_preempt_cipherlist %} +tls_preempt_cipherlist = {{ 'yes' if postfix_tls_preempt_cipherlist else 'no' }} +{% endif %} +{% if postfix_tls_eecdh_grade %} +smtpd_tls_eecdh_grade = {{ postfix_tls_eecdh_grade }} +{% endif %} +{% if postfix_tls_high_cipherlist %} +tls_high_cipherlist = {{ postfix_tls_high_cipherlist }} +{% endif %} +{% if postfix_tls_medium_cipherlist %} +tls_medium_cipherlist = {{ postfix_tls_medium_cipherlist }} +{% endif %} +{% if postfix_tls_dh_file %} +smtpd_tls_dh1024_param_file = /etc/postfix/dh.pem +{% endif %} alias_maps = cdb:/etc/aliases alias_database = cdb:/etc/aliases diff --git a/postfix/vars/tls-intermediate.yml b/postfix/vars/tls-intermediate.yml new file mode 100644 index 0000000000000000000000000000000000000000..588343d93a5b0796805225e147e8af819aabdc89 --- /dev/null +++ b/postfix/vars/tls-intermediate.yml @@ -0,0 +1,9 @@ +--- + +postfix_tls_protocols: '!SSLv2, !SSLv3, !TLSv1, !TLSv1.1' +postfix_tls_mandatory_ciphers: medium +postfix_tls_preempt_cipherlist: false +postfix_tls_eecdh_grade: null +postfix_tls_high_cipherlist: null +postfix_tls_dh_file: ffdhe2048.txt # ffdhe4096.txt +postfix_tls_medium_cipherlist: 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384' diff --git a/postfix/vars/tls-modern.yml b/postfix/vars/tls-modern.yml new file mode 100644 index 0000000000000000000000000000000000000000..2a2c9e7a70eefd8698b866a13d467265e5965766 --- /dev/null +++ b/postfix/vars/tls-modern.yml @@ -0,0 +1,9 @@ +--- + +postfix_tls_protocols: '!SSLv2, !SSLv3, !TLSv1, !TLSv1.1, !TLSv1.2' +postfix_tls_mandatory_ciphers: null +postfix_tls_preempt_cipherlist: false +postfix_tls_eecdh_grade: null +postfix_tls_high_cipherlist: null +postfix_tls_medium_cipherlist: null +postfix_tls_dh_file: null diff --git a/postfix/vars/tls-old.yml b/postfix/vars/tls-old.yml new file mode 100644 index 0000000000000000000000000000000000000000..a15cdc41553ce8761694b8cc39399fd3a985acd1 --- /dev/null +++ b/postfix/vars/tls-old.yml @@ -0,0 +1,9 @@ +--- + +postfix_tls_protocols: '!SSLv2, !SSLv3' +postfix_tls_mandatory_ciphers: medium +postfix_tls_preempt_cipherlist: true +postfix_tls_eecdh_grade: null +postfix_tls_high_cipherlist: null +postfix_tls_dh_file: ffdhe2048.txt # ffdhe4096.txt +postfix_tls_medium_cipherlist: 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA' diff --git a/postfix/vars/tls-previous.yml b/postfix/vars/tls-previous.yml new file mode 100644 index 0000000000000000000000000000000000000000..959869399132c412654c435add52bc1ebf7a9afc --- /dev/null +++ b/postfix/vars/tls-previous.yml @@ -0,0 +1,9 @@ +--- + +postfix_tls_protocols: '!SSLv2 !SSLv3' +postfix_tls_mandatory_ciphers: high +postfix_tls_preempt_cipherlist: null +postfix_tls_eecdh_grade: ultra +postfix_tls_high_cipherlist: "{{ tls_ciphers }}" +postfix_tls_medium_cipherlist: null +postfix_tls_dh_file: null