Postfix REQUIRETLS Support


Table of Contents

Introduction

(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

In this text, a perimeter MTA is a mail system that operates on the boundary of an administrative domain. It receives email messages for the domain, and/or delivers email messages on behalf of the domain.

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, assuming that the domain already publishes a valid DANE and/or STS policy.

If all you need is to receive messages with REQUIRETLS, and you do not insist on enforcing REQUIRETLS when sending or forwarding messages, then you can stop reading this document after adding the additional settings below.

NOTE: Such a configuration may be suitable for a personal domain, where the owner can decide what happens with all messages. For domains that receive messages for other people, a less radical approach may be better, as described in the sections that follow.

1 /etc/postfix/main.cf:
2     # Don't enforce REQUIRETLS when delivering mail with SMTP or LMTP.
3     smtp_requiretls_policy = opportunistic
4     lmtp_requiretls_policy = opportunistic
5     
6     # Don't detect or add a "Require-TLS-ESMTP: yes" header.
7     requiretls_esmtp_header = no

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 a more complete definition of this enforcement level, see the smtp_requiretls_policy parameter documentation.

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

 1 /etc/postfix/main.cf:
 2     smtp_tls_security_level = may
 3     requiretls_esmtp_header = yes
 4     lmtp_requiretls_policy = opportunistic
 5     smtp_requiretls_policy =
 6         inline:{
 7             {$mydomain = opportunistic}
 8             {.$mydomain = opportunistic}
 9             {localhost = opportunistic} }
10         cidr:{
11             {0.0.0.0/0 opportunistic}
12             {::/0 opportunistic} }
13       ...to be completed in section "Communication with external servers"...

Non-SMTP and non-LMTP content filters

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 enforcement levels:

For a more complete definition of these enforcement levels, see the smtp_requiretls_policy parameter documentation.

For sending mail with REQUIRETLS, the relevant Postfix 3.11 default settings are shown below, with one suggested setting in a comment (line 2).

The default settings below complete the earlier configuration for message stores and content filters, with an 'enforce' policy for external deliveries (line 13). You can disable the requiretls_esmtp_header feature (line 4) if a configuration does not use content inspection based on SMTPD_PROXY_README or FILTER_README.

 1 /etc/postfix/main.cf:
 2     # smtp_tls_policy_maps = ...dane/sts plugin...
 3     smtp_tls_security_level = may
 4     requiretls_esmtp_header = yes
 5     smtp_requiretls_policy =
 6         inline:{
 7             {$mydomain = opportunistic}
 8             {.$mydomain = opportunistic}
 9             {localhost = opportunistic} }
10         cidr:{
11             {0.0.0.0/0 opportunistic}
12             {::/0 opportunistic} }
13         enforce

The 'enforce' policy for external destinations is technically correct, but is likely to suffer from delivery failures because many domains do not publish a DANE or STS policy, and many MTAs support STARTTLS but not REQUIRETLS. The only benefit is that mail is returned as undeliverable, instead of being sent as plaintext.

Relaxing REQUIRETLS for external deliveries

It may be desirable to make REQUIRETLS work with today's infrastructure, by keeping the requirement for TLS, but relaxing the requirements that a remote server supports REQUIRETLS and that its server certificate matches a DANE or STS policy. The configuration below makes that change by replacing the default 'enforce' with 'opportunistic+starttls' (line 13).

 1 /etc/postfix/main.cf:
 2     smtp_tls_security_level = may
 3     # smtp_tls_policy_maps = ...dane/sts plugin...
 4     requiretls_esmtp_header = yes
 5     smtp_requiretls_policy =
 6         inline:{
 7             {$mydomain = opportunistic}
 8             {.$mydomain = opportunistic}
 9             {localhost = opportunistic} }
10         cidr:{
11             {0.0.0.0/0 opportunistic}
12             {::/0 opportunistic} }
13         opportunistic+starttls

This relaxes the requirement that every MTA in the forward path of a message supports REQUIRETLS, but in practice only one network hop needs to be secured: from a sender's perimeter MTA to a receiver's perimeter MTA. The network connections between user agents and their respective perimeters are assumed to be already secure.

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

The REQUIRETLS extension in ESMTP allows a sender to request that a message will be sent over connections that are protected with TLS. RFC 8689 defines two SMTP features:

Credits