Postfix REQUIRETLS Howto


Table of Contents

Introduction

(The REQUIRETLS extension in ESMTP allows a sender to request that a message will be sent over connections that are protected with TLS. For background information, see below for a REQUIRETLS quick summary .)

This document covers the Postfix default settings for using the REQUIRETLS extension. The purpose of these defaults is to make REQUIRETLS support usable in an existing environment, with a path towards the future.

The main issues with deploying REQUIRETLS are a lack of support in existing infrastructure:

REQUIRETLS for a perimeter MTA

Receiving inbound messages with REQUIRETLS requests

Postfix has one global parameter setting that controls REQUIRETLS support in all Postfix processes. The default setting is:

/etc/postfix/main.cf:
    requiretls_enable = yes

With this, the Postfix SMTP server will announce REQUIRETLS support, and more importantly, will receive messages from senders that for some reason request REQUIRETLS support -- messages that you would otherwise not receive.

Read the next sections if you also want to send or forward messages with REQUIRETLS and want to use a content filter based on FILTER_README or SMTPD_PROXY_README.

If, on the other hand, all you want is receiving messages with REQUIRETLS, without ever sending or forwarding messages with REQUIRETLS, then you can stop reading this document after adding the additional settings below.

/etc/postfix/main.cf:
    # Don't detect or add a "Require-TLS-ESMTP: yes" header.
    requiretls_esmtp_header = no
    # Don't enforce REQUIRETLS when delivering mail with SMTP or LMTP.
    smtp_requiretls_policy = disable
    lmtp_requiretls_policy = disable

The requiretls_esmtp_header feature enables support for a message header "Require-TLS-ESMTP: yes" that allows Postfix to propagate the sender's REQUIRETLS request through a content filter. This feature can safely be disabled if there is no need for content inspection based on SMTPD_PROXY_README or FILTER_README.

LMTP and SMTP-based message stores and content filters

REQUIRETLS is historically not supported by message stores such as Dovecot, and by content filters based on FILTER_README or SMTPD_PROXY_README. The settings below allow for that reality, while also preparing for future REQUIRETLS support.

The Postfix SMTP (LMTP) client supports a permissive REQUIRETLS policy that is suitable for communication with internal message stores and content filters based on FILTER_README or SMTPD_PROXY_README.

For REQUIRETLS, the relevant Postfix 3.11 configuration default settings are:

/etc/postfix/main.cf:
    smtp_tls_security_level = may
    requiretls_esmtp_header = yes
    lmtp_requiretls_policy = opportunistic
    smtp_requiretls_policy =
        inline:{
            {$mydomain = opportunistic}
            {.$mydomain = opportunistic}
            {localhost = opportunistic}
            {127.0.0.1 = opportunistic} }
        ...to be continued later...

The requiretls_esmtp_header setting enables support for a message header "Require-TLS-ESMTP: yes" that allows Postfix to propagate the sender's REQUIRETLS request through a content filter. This feature can safely be disabled if there is no need for content inspection based on SMTPD_PROXY_README or FILTER_README.

Non-SMTP or -LMTP content filters

The Postfix FILTER_README describes content inspection based on a pipe-to-command approach. For REQUIRETLS, the relevant Postfix 3.11 default setting is:

/etc/postfix/main.cf:
    requiretls_esmtp_header = yes

The requiretls_esmtp_header feature enables support for a message header "Require-TLS-ESMTP: yes" that allows Postfix to propagate the sender's REQUIRETLS request through a content filter. This feature can safely be disabled if there is no need for content inspection based on SMTPD_PROXY_README or FILTER_README.

Communication with external servers

For communication with external servers, the Postfix SMTP client supports multiple levels of enforcement:

For sending mail with REQUIRETLS, the relevant Postfix 3.11 default settings are (with one suggested comment):

/etc/postfix/main.cf:
    smtp_tls_security_level = may
    # smtp_tls_policy_maps = dane/sts plugin
    requiretls_esmtp_header = yes
    smtp_requiretls_policy =
        inline:{
            {$mydomain = opportunistic}
            {.$mydomain = opportunistic}
            {localhost = opportunistic}
            {127.0.0.1 = opportunistic} }
        opportunistic+starttls

This default reflects the reality that many domains do not publish a DANE or STS policy, that many MTAs support STARTTLS but not REQUIRETLS, and that most email will travel over just one hop: from the sender's perimeter to the receiver's perimeter.

Question: does opportunistic+starttls hit a "sweet spot", or do we need a level like enforce-certmatch that enforces everything except the secure server lookup and certificate match requirement? It's a slippery target...

An experiment: testing REQUIRETLS support

The 'opportunistic' enforcement level may be useful to discover REQUIRETLS support globally. The idea is to turn on REQUIRETLS for all outbound mail, and watch in Postfix TLS status logging how often delivery is logged as "requiretls" (all requirements satisfied), "requiretls:nocertmatch" (no DANE or STS policy, or certificate not trusted or not matched), "requiretls:none" (no REQUIRETLS support), or "requiretls:nostarttls". For more details on this logging format, see smtp_log_tls_feature_status.

Requesting REQUIRETLS without SMTP

There are two options:

Question: perhaps there needs to be a parameter setting to request REQUIRETLS for specific email sources or contexts?

Non-delivery notifications

By default, Postfix redacts an undeliverable REQUIRETLS message as described in RFC 8689, before returning it to the sender:

The relevant default setting is:

/etc/postfix/main.cf:
    requiretls_redact_dsn = yes

When a message was received with a "TLS-Required: no" header, and REQUIRETLS was not requested, then the "TLS-Required: no" header is copied to the delivery status notification.

REQUIRETLS quick summary

RFC 8689 defines two SMTP features:

Credits