Hardening Mail-In-A-Box transport security

After installing a trusted certificate, I performed the following to tighten up my mail server’s transport security. I still need to activate DNSSEC. I am also trying to figure out how to require mandatory TLS encryption.

Checkout my ssl-tools.net/mailservers test.

Test using checktls.com to verify the first cipher suite is being used (ECDHE-RSA-AES256-GCM-SHA384).

Post configuration

A message to Gmail: TLS1_2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256/256.

A message from Gmail: TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)

Postfix config

sudo vim /etc/postfix/main.cf

Add:

tls_ssl_options = NO_COMPRESSION

smtp_tls_protocols = TLSv1.2

smtpd_tls_protocols = TLSv1.2

smtp_tls_mandatory_protocols = TLSv1.2

smtpd_tls_mandatory_protocols = TLSv1.2

smtpd_tls_ask_ccert = yes

smtpd_tls_ccert_verifydepth = 2

smtp_tls_mandatory_ciphers = high

smtpd_tls_mandatory_ciphers = high

tls_high_cipherlist = ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:kEDH+AESGCM:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA

smtpd_tls_eecdh_grade = ultra

tls_eecdh_strong_curve = prime256v1

tls_eecdh_ultra_curve = secp384r1

tls_random_source = dev:/dev/urandom

tls_preempt_cipherlist = yes

smtp_tls_ciphers = high

Change:

smtpd_tls_ciphers = high

smtpd_tls_exclude_ciphers = aNULL, eNULL, EXPORT, DES, RC4, MD5, PSK, aECDH, EDH-DSS-DES-CBC3-SHA, EDH-RSA-DES-CDB3-SHA, KRB5-DES, CBC3-SHA

Then:

sudo vim /etc/postfix/master.cf

Add:

-o smtpd_enforce_tls=yes

Change:

-o smtpd_tls_mandatory_protocols = TLSv1.2

-o smtpd_tls_wrappermode = yes

Note: Activating “smtpd_tls_wrappermode” allows a remote client to connect with explicit SSL/TLS over port 587 instead of STARTTLS, which is ideal.

Dovecot config

sudo vim /etc/dovecot/conf.d/10-ssl.conf

Add:

ssl_dh_parameters_length = 2048

Change:

ssl_protocols = TLSv1.2

ssl_cipher_list = ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:kEDH+AESGCM:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA

ssl_prefer_server_ciphers = yes

Restart services

sudo service dovecot restart

sudo service postfix restart

Lead by example

Saddening advice from the Postfix TLS Readme:

Despite the potential for eliminating “man-in-the-middle” and other attacks, mandatory certificate trust chain and subject name verification is not viable as a default Internet mail delivery policy. Most MX hosts do not support TLS at all, and a significant portion of TLS enabled MTAs use self-signed certificates, or certificates that are signed by a private Certification Authority. On a machine that delivers mail to the Internet, you should not configure mandatory server certificate verification as a default policy.

References

weakdh.org

sparkslinux.wordpress.com