1 P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx T
\bTL
\bLS
\bS S
\bSu
\bup
\bpp
\bpo
\bor
\brt
\bt
3 -------------------------------------------------------------------------------
5 W
\bWA
\bAR
\bRN
\bNI
\bIN
\bNG
\bG
7 By turning on TLS support in Postfix, you not only get the ability to encrypt
8 mail and to authenticate remote SMTP clients or servers. You also turn on
9 thousands and thousands of lines of OpenSSL library code. Assuming that OpenSSL
10 is written as carefully as Wietse's own code, every 1000 lines introduce one
11 additional bug into Postfix.
13 W
\bWh
\bha
\bat
\bt P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx T
\bTL
\bLS
\bS s
\bsu
\bup
\bpp
\bpo
\bor
\brt
\bt d
\bdo
\boe
\bes
\bs f
\bfo
\bor
\br y
\byo
\bou
\bu
15 Transport Layer Security (TLS, formerly called SSL) provides certificate-based
16 authentication and encrypted sessions. An encrypted session protects the
17 information that is transmitted with SMTP mail or with SASL authentication.
19 This document describes a TLS user interface that was introduced with Postfix
20 version 2.3. Support for an older user interface is documented in
21 TLS_LEGACY_README, which also describes the differences between Postfix and the
22 third-party patch on which Postfix version 2.2 TLS support was based.
24 Topics covered in this document:
26 * How Postfix TLS support works
27 * Building Postfix with TLS support
28 * SMTP Server specific settings
29 * SMTP Client specific settings
30 * TLS manager specific settings
34 And last but not least, for the impatient:
36 * Getting started, quick and dirty
38 H
\bHo
\bow
\bw P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx T
\bTL
\bLS
\bS s
\bsu
\bup
\bpp
\bpo
\bor
\brt
\bt w
\bwo
\bor
\brk
\bks
\bs
40 The diagram below shows the main elements of the Postfix TLS architecture and
41 their relationships. Colored boxes with numbered names represent Postfix daemon
42 programs. Other colored boxes represent storage elements.
44 * The smtpd(8) server implements the SMTP over TLS server side.
46 * The smtp(8) client implements the SMTP over TLS client side.
48 * The tlsmgr(8) server maintains the pseudo-random number generator (PRNG)
49 that seeds the TLS engines in the smtpd(8) server and smtp(8) client
50 processes, and maintains the TLS session key cache files.
52 <---seed---- ----seed--->
53 Network-> smtpd(8) tlsmgr(8) smtp(8) ->Network
54 <-key/cert-> <-key/cert->
62 key cache file key cache
64 B
\bBu
\bui
\bil
\bld
\bdi
\bin
\bng
\bg P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx w
\bwi
\bit
\bth
\bh T
\bTL
\bLS
\bS s
\bsu
\bup
\bpp
\bpo
\bor
\brt
\bt
66 These instructions assume that you build Postfix from source code as described
67 in the INSTALL document. Some modification may be required if you build Postfix
68 from a vendor-specific source package.
70 To build Postfix with TLS support, first we need to generate the make(1) files
71 with the necessary definitions. This is done by invoking the command "make
72 makefiles" in the Postfix top-level directory and with arguments as shown next.
74 N
\bNO
\bOT
\bTE
\bE:
\b: D
\bDo
\bo n
\bno
\bot
\bt u
\bus
\bse
\be G
\bGn
\bnu
\bu T
\bTL
\bLS
\bS.
\b. I
\bIt
\bt w
\bwi
\bil
\bll
\bl s
\bsp
\bpo
\bon
\bnt
\bta
\ban
\bne
\beo
\bou
\bus
\bsl
\bly
\by t
\bte
\ber
\brm
\bmi
\bin
\bna
\bat
\bte
\be a
\ba P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx d
\bda
\bae
\bem
\bmo
\bon
\bn
75 p
\bpr
\bro
\boc
\bce
\bes
\bss
\bs w
\bwi
\bit
\bth
\bh e
\bex
\bxi
\bit
\bt s
\bst
\bta
\bat
\btu
\bus
\bs c
\bco
\bod
\bde
\be 2
\b2,
\b, i
\bin
\bns
\bst
\bte
\bea
\bad
\bd o
\bof
\bf a
\bal
\bll
\blo
\bow
\bwi
\bin
\bng
\bg P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx t
\bto
\bo 1
\b1)
\b) r
\bre
\bep
\bpo
\bor
\brt
\bt t
\bth
\bhe
\be
76 e
\ber
\brr
\bro
\bor
\br t
\bto
\bo t
\bth
\bhe
\be m
\bma
\bai
\bil
\bll
\blo
\bog
\bg f
\bfi
\bil
\ble
\be,
\b, a
\ban
\bnd
\bd t
\bto
\bo 2
\b2)
\b) p
\bpr
\bro
\bov
\bvi
\bid
\bde
\be p
\bpl
\bla
\bai
\bin
\bnt
\bte
\bex
\bxt
\bt s
\bse
\ber
\brv
\bvi
\bic
\bce
\be w
\bwh
\bhe
\ber
\bre
\be t
\bth
\bhi
\bis
\bs i
\bis
\bs
77 a
\bap
\bpp
\bpr
\bro
\bop
\bpr
\bri
\bia
\bat
\bte
\be.
\b.
79 * If the OpenSSL include files (such as ssl.h) are in directory /usr/include/
80 openssl, and the OpenSSL libraries (such as libssl.so and libcrypto.so) are
81 in directory /usr/lib:
83 % m
\bma
\bak
\bke
\be t
\bti
\bid
\bdy
\by # if you have left-over files from a previous build
84 % m
\bma
\bak
\bke
\be m
\bma
\bak
\bke
\bef
\bfi
\bil
\ble
\bes
\bs C
\bCC
\bCA
\bAR
\bRG
\bGS
\bS=
\b="
\b"-
\b-D
\bDU
\bUS
\bSE
\bE_
\b_T
\bTL
\bLS
\bS"
\b" A
\bAU
\bUX
\bXL
\bLI
\bIB
\bBS
\bS=
\b="
\b"-
\b-l
\bls
\bss
\bsl
\bl -
\b-l
\blc
\bcr
\bry
\byp
\bpt
\bto
\bo"
\b"
86 * If the OpenSSL include files (such as ssl.h) are in directory /usr/local/
87 include/openssl, and the OpenSSL libraries (such as libssl.so and
88 libcrypto.so) are in directory /usr/local/lib:
90 % m
\bma
\bak
\bke
\be t
\bti
\bid
\bdy
\by # if you have left-over files from a previous build
91 % m
\bma
\bak
\bke
\be m
\bma
\bak
\bke
\bef
\bfi
\bil
\ble
\bes
\bs C
\bCC
\bCA
\bAR
\bRG
\bGS
\bS=
\b="
\b"-
\b-D
\bDU
\bUS
\bSE
\bE_
\b_T
\bTL
\bLS
\bS -
\b-I
\bI/
\b/u
\bus
\bsr
\br/
\b/l
\blo
\boc
\bca
\bal
\bl/
\b/i
\bin
\bnc
\bcl
\blu
\bud
\bde
\be"
\b" \
\b\
92 A
\bAU
\bUX
\bXL
\bLI
\bIB
\bBS
\bS=
\b="
\b"-
\b-L
\bL/
\b/u
\bus
\bsr
\br/
\b/l
\blo
\boc
\bca
\bal
\bl/
\b/l
\bli
\bib
\bb -
\b-l
\bls
\bss
\bsl
\bl -
\b-l
\blc
\bcr
\bry
\byp
\bpt
\bto
\bo"
\b"
94 On Solaris, specify the -R option as shown below:
96 % m
\bma
\bak
\bke
\be t
\bti
\bid
\bdy
\by # if you have left-over files from a previous build
97 % m
\bma
\bak
\bke
\be m
\bma
\bak
\bke
\bef
\bfi
\bil
\ble
\bes
\bs C
\bCC
\bCA
\bAR
\bRG
\bGS
\bS=
\b="
\b"-
\b-D
\bDU
\bUS
\bSE
\bE_
\b_T
\bTL
\bLS
\bS -
\b-I
\bI/
\b/u
\bus
\bsr
\br/
\b/l
\blo
\boc
\bca
\bal
\bl/
\b/i
\bin
\bnc
\bcl
\blu
\bud
\bde
\be"
\b" \
\b\
98 A
\bAU
\bUX
\bXL
\bLI
\bIB
\bBS
\bS=
\b="
\b"-
\b-R
\bR/
\b/u
\bus
\bsr
\br/
\b/l
\blo
\boc
\bca
\bal
\bl/
\b/l
\bli
\bib
\bb -
\b-L
\bL/
\b/u
\bus
\bsr
\br/
\b/l
\blo
\boc
\bca
\bal
\bl/
\b/l
\bli
\bib
\bb -
\b-l
\bls
\bss
\bsl
\bl -
\b-l
\blc
\bcr
\bry
\byp
\bpt
\bto
\bo"
\b"
100 If you need to apply other customizations (such as Berkeley DB databases,
101 MySQL, PostgreSQL, LDAP or SASL), see the respective Postfix README documents,
102 and combine their "make makefiles" instructions with the instructions above:
104 % m
\bma
\bak
\bke
\be t
\bti
\bid
\bdy
\by # if you have left-over files from a previous build
105 % m
\bma
\bak
\bke
\be m
\bma
\bak
\bke
\bef
\bfi
\bil
\ble
\bes
\bs C
\bCC
\bCA
\bAR
\bRG
\bGS
\bS=
\b="
\b"-
\b-D
\bDU
\bUS
\bSE
\bE_
\b_T
\bTL
\bLS
\bS \
\b\
106 (
\b(o
\bot
\bth
\bhe
\ber
\br -
\b-D
\bD o
\bor
\br -
\b-I
\bI o
\bop
\bpt
\bti
\bio
\bon
\bns
\bs)
\b)"
\b" \
\b\
107 A
\bAU
\bUX
\bXL
\bLI
\bIB
\bBS
\bS=
\b="
\b"-
\b-l
\bls
\bss
\bsl
\bl -
\b-l
\blc
\bcr
\bry
\byp
\bpt
\bto
\bo \
\b\
108 (
\b(o
\bot
\bth
\bhe
\ber
\br -
\b-l
\bl o
\bop
\bpt
\bti
\bio
\bon
\bns
\bs f
\bfo
\bor
\br l
\bli
\bib
\bbr
\bra
\bar
\bri
\bie
\bes
\bs i
\bin
\bn /
\b/u
\bus
\bsr
\br/
\b/l
\bli
\bib
\bb)
\b) \
\b\
109 (
\b(-
\b-L
\bL/
\b/p
\bpa
\bat
\bth
\bh/
\b/n
\bna
\bam
\bme
\be +
\b+ -
\b-l
\bl o
\bop
\bpt
\bti
\bio
\bon
\bns
\bs f
\bfo
\bor
\br o
\bot
\bth
\bhe
\ber
\br l
\bli
\bib
\bbr
\bra
\bar
\bri
\bie
\bes
\bs)
\b)"
\b"
111 To complete the build process, see the Postfix INSTALL instructions. Postfix
112 has TLS support turned off by default, so you can start using Postfix as soon
115 S
\bSM
\bMT
\bTP
\bP S
\bSe
\ber
\brv
\bve
\ber
\br s
\bsp
\bpe
\bec
\bci
\bif
\bfi
\bic
\bc s
\bse
\bet
\btt
\bti
\bin
\bng
\bgs
\bs
117 Topics covered in this section:
119 * Server-side certificate and private key configuration
120 * Server-side TLS activity logging
121 * Enabling TLS in the Postfix SMTP server
122 * Client certificate verification
123 * Supporting AUTH over TLS only
124 * Server-side TLS session cache
125 * Server access control
126 * Server-side cipher controls
127 * Miscellaneous server controls
129 S
\bSe
\ber
\brv
\bve
\ber
\br-
\b-s
\bsi
\bid
\bde
\be c
\bce
\ber
\brt
\bti
\bif
\bfi
\bic
\bca
\bat
\bte
\be a
\ban
\bnd
\bd p
\bpr
\bri
\biv
\bva
\bat
\bte
\be k
\bke
\bey
\by c
\bco
\bon
\bnf
\bfi
\big
\bgu
\bur
\bra
\bat
\bti
\bio
\bon
\bn
131 In order to use TLS, the Postfix SMTP server generally needs a certificate and
132 a private key. Both must be in "PEM" format. The private key must not be
133 encrypted, meaning: the key must be accessible without a password. The
134 certificate and private key may be in the same file, in which case the
135 certificate file should be owned by "root" and not be readable by any other
136 user. If the key is stored separately, this applies to the key file only, and
137 the certificate file may be "world-readable".
139 Public Internet MX hosts without certificates signed by a "reputable" CA must
140 generate, and be prepared to present to most clients, a self-signed or private-
141 CA signed certificate. The remote SMTP client will generally not be able to
142 authenticate the self-signed certificate, but unless the client is running
143 Postfix 2.3 or similar software, it will still insist on a server certificate.
145 For servers that are n
\bno
\bot
\bt public Internet MX hosts, Postfix supports
146 configurations with no certificates. This entails the use of just the anonymous
147 TLS ciphers, which are not supported by typical SMTP clients. Since such
148 clients will not, as a rule, fall back to plain text after a TLS handshake
149 failure, a certificate-less Postfix SMTP server will be unable to receive email
150 from most TLS enabled clients. To avoid accidental configurations with no
151 certificates, Postfix enables certificate-less operation only when the
152 administrator explicitly sets "smtpd_tls_cert_file = none". This ensures that
153 new Postfix SMTP server configurations will not accidentally run with no
156 RSA, DSA and ECDSA (Postfix >= 2.6) certificates are supported. Typically you
157 will only have RSA certificates issued by a commercial CA. In addition, the
158 tools supplied with OpenSSL will by default issue RSA certificates. You can
159 configure all three at the same time, in which case the cipher used determines
160 which certificate is presented. For Netscape and OpenSSL clients without
161 special cipher choices, the RSA certificate is preferred.
163 To enable a remote SMTP client to verify the Postfix SMTP server certificate,
164 the issuing CA certificates must be made available to the client. You should
165 include the required certificates in the server certificate file, the server
166 certificate first, then the issuing CA(s) (bottom-up order).
168 Example: the certificate for "server.example.com" was issued by "intermediate
169 CA" which itself has a certificate issued by "root CA". Create the server.pem
172 % c
\bca
\bat
\bt s
\bse
\ber
\brv
\bve
\ber
\br_
\b_c
\bce
\ber
\brt
\bt.
\b.p
\bpe
\bem
\bm i
\bin
\bnt
\bte
\ber
\brm
\bme
\bed
\bdi
\bia
\bat
\bte
\be_
\b_C
\bCA
\bA.
\b.p
\bpe
\bem
\bm >
\b> s
\bse
\ber
\brv
\bve
\ber
\br.
\b.p
\bpe
\bem
\bm
174 A Postfix SMTP server certificate supplied here must be usable as SSL server
175 certificate and hence pass the "openssl verify -purpose sslserver ..." test.
177 A client that trusts the root CA has a local copy of the root CA certificate,
178 so it is not necessary to include the root CA certificate here. Leaving it out
179 of the "server.pem" file reduces the overhead of the TLS exchange.
181 If you want the Postfix SMTP server to accept remote SMTP client certificates
182 issued by these CAs, append the root certificate to $smtpd_tls_CAfile or
183 install it in the $smtpd_tls_CApath directory.
185 RSA key and certificate examples:
187 /etc/postfix/main.cf:
188 smtpd_tls_cert_file = /etc/postfix/server.pem
189 smtpd_tls_key_file = $smtpd_tls_cert_file
191 Their DSA counterparts:
193 /etc/postfix/main.cf:
194 smtpd_tls_dcert_file = /etc/postfix/server-dsa.pem
195 smtpd_tls_dkey_file = $smtpd_tls_dcert_file
197 Their ECDSA counterparts (Postfix >= 2.6 + OpenSSL >= 0.9.9):
199 /etc/postfix/main.cf:
200 # Most clients will not be ECDSA capable, so you will likely also need
201 # an RSA or DSA certificate and private key.
203 smtpd_tls_eccert_file = /etc/postfix/server-ecdsa.pem
204 smtpd_tls_eckey_file = $smtpd_tls_eccert_file
206 TLS without certificates for servers serving exclusively anonymous-cipher
209 /etc/postfix/main.cf:
210 smtpd_tls_cert_file = none
212 To verify a remote SMTP client certificate, the Postfix SMTP server needs to
213 trust the certificates of the issuing certification authorities. These
214 certificates in "PEM" format can be stored in a single $smtpd_tls_CAfile or in
215 multiple files, one CA per file in the $smtpd_tls_CApath directory. If you use
216 a directory, don't forget to create the necessary "hash" links with:
218 # $
\b$O
\bOP
\bPE
\bEN
\bNS
\bSS
\bSL
\bL_
\b_H
\bHO
\bOM
\bME
\bE/
\b/b
\bbi
\bin
\bn/
\b/c
\bc_
\b_r
\bre
\beh
\bha
\bas
\bsh
\bh /
\b/p
\bpa
\bat
\bth
\bh/
\b/t
\bto
\bo/
\b/d
\bdi
\bir
\bre
\bec
\bct
\bto
\bor
\bry
\by
220 The $smtpd_tls_CAfile contains the CA certificates of one or more trusted CAs.
221 The file is opened (with root privileges) before Postfix enters the optional
222 chroot jail and so need not be accessible from inside the chroot jail.
224 Additional trusted CAs can be specified via the $smtpd_tls_CApath directory, in
225 which case the certificates are read (with $mail_owner privileges) from the
226 files in the directory when the information is needed. Thus, the
227 $smtpd_tls_CApath directory needs to be accessible inside the optional chroot
230 When you configure the Postfix SMTP server to request client certificates, the
231 DNs of certificate authorities in $smtpd_tls_CAfile are sent to the client, in
232 order to allow it to choose an identity signed by a CA you trust. If no
233 $smtpd_tls_CAfile is specified, no preferred CA list is sent, and the client is
234 free to choose an identity signed by any CA. Many clients use a fixed identity
235 regardless of the preferred CA list and you may be able to reduce TLS
236 negotiation overhead by installing client CA certificates mostly or only in
237 $smtpd_tls_CApath. In the latter case you need not specify a $smtpd_tls_CAfile.
239 Note, that unless client certificates are used to allow greater access to TLS
240 authenticated clients, it is best to not ask for client certificates at all, as
241 in addition to increased overhead some clients (notably in some cases qmail)
242 are unable to complete the TLS handshake when client certificates are
247 /etc/postfix/main.cf:
248 smtpd_tls_CAfile = /etc/postfix/CAcert.pem
249 smtpd_tls_CApath = /etc/postfix/certs
251 S
\bSe
\ber
\brv
\bve
\ber
\br-
\b-s
\bsi
\bid
\bde
\be T
\bTL
\bLS
\bS a
\bac
\bct
\bti
\biv
\bvi
\bit
\bty
\by l
\blo
\bog
\bgg
\bgi
\bin
\bng
\bg
253 To get additional information about Postfix SMTP server TLS activity you can
254 increase the log level from 0..4. Each logging level also includes the
255 information that is logged at a lower logging level.
257 0 Disable logging of TLS activity.
259 1 Log TLS handshake and certificate information.
261 2 Log levels during TLS negotiation.
263 3 Log hexadecimal and ASCII dump of TLS negotiation process
265 4 Log hexadecimal and ASCII dump of complete transmission after STARTTLS
267 Use log level 3 only in case of problems. Use of log level 4 is strongly
272 /etc/postfix/main.cf:
273 smtpd_tls_loglevel = 0
275 To include information about the protocol and cipher used as well as the client
276 and issuer CommonName into the "Received:" message header, set the
277 smtpd_tls_received_header variable to true. The default is no, as the
278 information is not necessarily authentic. Only information recorded at the
279 final destination is reliable, since the headers may be changed by intermediate
284 /etc/postfix/main.cf:
285 smtpd_tls_received_header = yes
287 E
\bEn
\bna
\bab
\bbl
\bli
\bin
\bng
\bg T
\bTL
\bLS
\bS i
\bin
\bn t
\bth
\bhe
\be P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx S
\bSM
\bMT
\bTP
\bP s
\bse
\ber
\brv
\bve
\ber
\br
289 By default, TLS is disabled in the Postfix SMTP server, so no difference to
290 plain Postfix is visible. Explicitly switch it on with
291 "smtpd_tls_security_level = may" (Postfix 2.3 and later) or "smtpd_use_tls =
292 yes" (obsolete but still supported).
296 /etc/postfix/main.cf:
297 # Postfix 2.3 and later
298 smtpd_tls_security_level = may
299 # Obsolete, but still supported
302 With this, the Postfix SMTP server announces STARTTLS support to remote SMTP
303 clients, but does not require that clients use TLS encryption.
305 Note: when an unprivileged user invokes "sendmail -bs", STARTTLS is never
306 offered due to insufficient privileges to access the Postfix SMTP server
307 private key. This is intended behavior.
309 You can ENFORCE the use of TLS, so that the Postfix SMTP server announces
310 STARTTLS and accepts no mail without TLS encryption, by setting
311 "smtpd_tls_security_level = encrypt" (Postfix 2.3 and later) or
312 "smtpd_enforce_tls = yes" (obsolete but still supported). According to RFC 2487
313 this MUST NOT be applied in case of a publicly-referenced Postfix SMTP server.
314 This option is off by default and should only seldom be used.
318 /etc/postfix/main.cf:
319 # Postfix 2.3 and later
320 smtpd_tls_security_level = encrypt
321 # Obsolete, but still supported
322 smtpd_enforce_tls = yes
324 TLS is sometimes used in the non-standard "wrapper" mode where a server always
325 uses TLS, instead of announcing STARTTLS support and waiting for remote SMTP
326 clients to request TLS service. Some clients, namely Outlook [Express] prefer
327 the "wrapper" mode. This is true for OE (Win32 < 5.0 and Win32 >=5.0 when run
328 on a port<>25 and OE (5.01 Mac on all ports).
330 It is strictly discouraged to use this mode from main.cf. If you want to
331 support this service, enable a special port in master.cf and specify "-
332 o smtpd_tls_wrappermode=yes" (note: no space around the "=") as an smtpd(8)
333 command line option. Port 465 (smtps) was once chosen for this feature.
337 /etc/postfix/master.cf:
338 smtps inet n - n - - smtpd
339 -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes
341 C
\bCl
\bli
\bie
\ben
\bnt
\bt c
\bce
\ber
\brt
\bti
\bif
\bfi
\bic
\bca
\bat
\bte
\be v
\bve
\ber
\bri
\bif
\bfi
\bic
\bca
\bat
\bti
\bio
\bon
\bn
343 To receive a remote SMTP client certificate, the Postfix SMTP server must
344 explicitly ask for one (any contents of $smtpd_tls_CAfile are also sent to the
345 client as a hint for choosing a certificate from a suitable CA). Unfortunately,
346 Netscape clients will either complain if no matching client certificate is
347 available or will offer the user client a list of certificates to choose from.
348 Additionally some MTAs (notably some versions of qmail) are unable to complete
349 TLS negotiation when client certificates are requested, and abort the SMTP
350 session. So this option is "off" by default. You will however need the
351 certificate if you want to use certificate based relaying with, for example,
352 the permit_tls_clientcerts feature. A server that wants client certificates
353 must first present its own certificate. While Postfix 2.3 by default offers
354 anonymous ciphers to remote SMTP clients, these are automatically suppressed
355 when the Postfix SMTP server is configured to ask for client certificates.
359 /etc/postfix/main.cf:
360 smtpd_tls_ask_ccert = yes
361 # Postfix 2.3 and later
362 smtpd_tls_security_level = may
363 # Obsolete, but still supported
366 When TLS is enforced you may also decide to REQUIRE a remote SMTP client
367 certificate for all TLS connections, by setting "smtpd_tls_req_ccert = yes".
368 This feature implies "smtpd_tls_ask_ccert = yes". When TLS is not enforced,
369 "smtpd_tls_req_ccert = yes" is ignored and a warning is logged.
373 /etc/postfix/main.cf:
374 smtpd_tls_req_ccert = yes
375 # Postfix 2.3 and later
376 smtpd_tls_security_level = encrypt
377 # Obsolete, but still supported
378 smtpd_enforce_tls = yes
380 The client certificate verification depth is specified with the main.cf
381 smtpd_tls_ccert_verifydepth parameter. The default verification depth is 9 (the
382 OpenSSL default), for compatibility with Postfix versions before 2.5 where
383 smtpd_tls_ccert_verifydepth was ignored. When you configure trust in a root CA,
384 it is not necessary to explicitly trust intermediary CAs signed by the root CA,
385 unless $smtpd_tls_ccert_verifydepth is less than the number of CAs in the
386 certificate chain for the clients of interest. With a verify depth of 1 you can
387 only verify certificates directly signed by a trusted CA, and all trusted
388 intermediary CAs need to be configured explicitly. With a verify depth of 2 you
389 can verify clients signed by a root CA or a direct intermediary CA (so long as
390 the client is correctly configured to supply its intermediate CA certificate).
394 /etc/postfix/main.cf:
395 smtpd_tls_ccert_verifydepth = 2
397 S
\bSu
\bup
\bpp
\bpo
\bor
\brt
\bti
\bin
\bng
\bg A
\bAU
\bUT
\bTH
\bH o
\bov
\bve
\ber
\br T
\bTL
\bLS
\bS o
\bon
\bnl
\bly
\by
399 Sending AUTH data over an unencrypted channel poses a security risk. When TLS
400 layer encryption is required ("smtpd_tls_security_level = encrypt" or the
401 obsolete "smtpd_enforce_tls = yes"), the Postfix SMTP server will announce and
402 accept AUTH only after the TLS layer has been activated with STARTTLS. When TLS
403 layer encryption is optional ("smtpd_tls_security_level = may" or the obsolete
404 "smtpd_enforce_tls = no"), it may however still be useful to only offer AUTH
405 when TLS is active. To maintain compatibility with non-TLS clients, the default
406 is to accept AUTH without encryption. In order to change this behavior, set
407 "smtpd_tls_auth_only = yes".
411 /etc/postfix/main.cf:
412 smtpd_tls_auth_only = no
414 S
\bSe
\ber
\brv
\bve
\ber
\br-
\b-s
\bsi
\bid
\bde
\be T
\bTL
\bLS
\bS s
\bse
\bes
\bss
\bsi
\bio
\bon
\bn c
\bca
\bac
\bch
\bhe
\be
416 The Postfix SMTP server and the remote SMTP client negotiate a session, which
417 takes some computer time and network bandwidth. By default, this session
418 information is cached only in the smtpd(8) process actually using this session
419 and is lost when the process terminates. To share the session information
420 between multiple smtpd(8) processes, a persistent session cache can be used.
421 You can specify any database type that can store objects of several kbytes and
422 that supports the sequence operator. DBM databases are not suitable because
423 they can only store small objects. The cache is maintained by the tlsmgr(8)
424 process, so there is no problem with concurrent access. Session caching is
425 highly recommended, because the cost of repeatedly negotiating TLS session keys
430 /etc/postfix/main.cf:
431 smtpd_tls_session_cache_database = btree:/var/db/postfix/smtpd_scache
433 Note: as of version 2.5, Postfix no longer uses root privileges when opening
434 this file. The file should now be stored under the Postfix-owned
435 data_directory. As a migration aid, an attempt to open the file under a non-
436 Postfix directory is redirected to the Postfix-owned data_directory, and a
439 Cached Postfix SMTP server session information expires after a certain amount
440 of time. Postfix/TLS does not use the OpenSSL default of 300s, but a longer
441 time of 3600sec (=1 hour). RFC 2246 recommends a maximum of 24 hours.
445 /etc/postfix/main.cf:
446 smtpd_tls_session_cache_timeout = 3600s
448 When the Postfix SMTP server does not save TLS sessions to an external cache
449 database, client-side session caching is unlikely to be useful. To prevent such
450 wastage, the Postfix SMTP server can be configured to not issue TLS session
451 ids. By default the Postfix SMTP server always issues TLS session ids. This
452 works around known interoperability issues with some MUAs, and prevents
453 possible interoperability issues with other MTAs.
457 smtpd_tls_always_issue_session_ids = no
459 S
\bSe
\ber
\brv
\bve
\ber
\br a
\bac
\bcc
\bce
\bes
\bss
\bs c
\bco
\bon
\bnt
\btr
\bro
\bol
\bl
461 Postfix TLS support introduces three additional features for Postfix SMTP
462 server access control:
464 permit_tls_clientcerts
465 Allow the remote SMTP client request if the client certificate
466 fingerprint is listed in the client certificate table (see
467 relay_clientcerts discussion below).
469 permit_tls_all_clientcerts
470 Allow the remote SMTP client request if the client certificate passes
471 trust chain verification. Useful with private-label CAs that only issue
472 certificates to trusted clients (and not otherwise).
474 check_ccert_access type:table
475 Use the remote SMTP client certificate fingerprint as the lookup key
476 for the specified access(5) table.
478 The digest algorithm used to construct the client certificate fingerprints is
479 specified with the main.cf smtpd_tls_fingerprint_digest parameter. The default
480 is "md5", for compatibility with Postfix versions < 2.5.
482 The permit_tls_all_clientcerts feature must be used with caution, because it
483 can result in too many access permissions. Use this feature only if a special
484 CA issues the client certificates, and only if this CA is listed as trusted CA.
485 If other CAs are trusted, any owner of a valid client certificate would be
486 authorized. The permit_tls_all_clientcerts feature can be practical for a
487 specially created email relay server.
489 It is however recommended to stay with the permit_tls_clientcerts feature and
490 list all certificates via $relay_clientcerts, as permit_tls_all_clientcerts
491 does not permit any control when a certificate must no longer be used (e.g. an
496 /etc/postfix/main.cf:
497 smtpd_recipient_restrictions =
499 permit_tls_clientcerts
500 reject_unauth_destination
503 Example: Postfix lookup tables are in the form of (key, value) pairs. Since we
504 only need the key, the value can be chosen freely, e.g. the name of the user or
507 /etc/postfix/main.cf:
508 relay_clientcerts = hash:/etc/postfix/relay_clientcerts
510 /etc/postfix/relay_clientcerts:
511 D7:04:2F:A7:0B:8C:A5:21:FA:31:77:E1:41:8A:EE:80 lutzpc.at.home
513 S
\bSe
\ber
\brv
\bve
\ber
\br-
\b-s
\bsi
\bid
\bde
\be c
\bci
\bip
\bph
\bhe
\ber
\br c
\bco
\bon
\bnt
\btr
\bro
\bol
\bls
\bs
515 The description below is for Postfix 2.3; for Postfix < 2.3 the
516 smtpd_tls_cipherlist parameter specifies the acceptable ciphers as an explicit
517 OpenSSL cipherlist. The obsolete setting applies even when TLS encryption is
518 not enforced. Use of this control on public MX hosts is strongly discouraged.
520 The Postfix SMTP server supports 5 distinct cipher security levels as specified
521 by the smtpd_tls_mandatory_ciphers configuration parameter, which determines
522 the cipher grade with mandatory TLS encryption. The default value is "medium"
523 which is essentially 128-bit encryption or better. With opportunistic TLS
524 encryption, the minimum accepted cipher grade is typically "export". The
525 corresponding smtpd_tls_ciphers parameter (Postfix >= 2.6) controls the cipher
526 grade used with opportunistic TLS.
528 By default anonymous ciphers are enabled. They are automatically disabled when
529 remote SMTP client certificates are requested. If clients are expected to
530 always verify the Postfix SMTP server certificate you may want to disable
531 anonymous ciphers by setting "smtpd_tls_mandatory_exclude_ciphers = aNULL" or
532 "smtpd_tls_exclude_ciphers = aNULL", as appropriate. One can't force a remote
533 SMTP client to check the server certificate, so excluding anonymous ciphers is
534 generally unnecessary.
536 The "smtpd_tls_ciphers" configuration parameter (Postfix >= 2.6) provides
537 control over the minimum cipher grade for opportunistic TLS. With Postfix <
538 2.6, the minimum opportunistic TLS cipher grade is always "export".
540 With mandatory TLS encryption, the Postfix SMTP server will by default only use
541 SSLv3 or TLSv1. SSLv2 is only used when TLS encryption is optional. The
542 mandatory TLS protocol list is specified via the smtpd_tls_mandatory_protocols
543 configuration parameter. The corresponding smtpd_tls_protocols parameter
544 (Postfix >= 2.6) controls the SSL/TLS protocols used with opportunistic TLS.
546 For a server that is not a public Internet MX host, Postfix (>= 2.3) supports
547 configurations with no server certificates that use o
\bon
\bnl
\bly
\by the anonymous ciphers.
548 This is enabled by explicitly setting "smtpd_tls_cert_file = none" and not
549 specifying an smtpd_tls_dcert_file or smtpd_tls_eccert_file.
551 Example, MSA that requires TLSv1, not SSLv2 or SSLv3, with high grade ciphers:
553 /etc/postfix/main.cf:
554 smtpd_tls_cert_file = /etc/postfix/cert.pem
555 smtpd_tls_key_file = /etc/postfix/key.pem
556 smtpd_tls_mandatory_ciphers = high
557 smtpd_tls_mandatory_exclude_ciphers = aNULL, MD5
558 smtpd_tls_security_level = encrypt
559 smtpd_tls_mandatory_protocols = TLSv1
560 # Also available with Postfix >= 2.5:
561 smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3
563 If you want to take advantage of ciphers with ephemeral Diffie-Hellman (EDH)
564 key exchange (this offers "forward-secrecy"), DH parameters are needed. Instead
565 of using the built-in DH parameters for both 1024-bit (non-export ciphers) and
566 512-bit (export ciphers), it is better to generate your own parameters, since
567 otherwise it would "pay" for a possible attacker to start a brute force attack
568 against parameters that are used by everybody. Postfix defaults to compiled-in
569 parameters that are shared by all Postfix users who don't generate their own
572 To generate your own set of DH parameters, use:
574 % o
\bop
\bpe
\ben
\bns
\bss
\bsl
\bl g
\bge
\ben
\bnd
\bdh
\bh -
\b-o
\bou
\but
\bt /
\b/e
\bet
\btc
\bc/
\b/p
\bpo
\bos
\bst
\btf
\bfi
\bix
\bx/
\b/d
\bdh
\bh_
\b_5
\b51
\b12
\b2.
\b.p
\bpe
\bem
\bm -
\b-2
\b2 5
\b51
\b12
\b2
575 % o
\bop
\bpe
\ben
\bns
\bss
\bsl
\bl g
\bge
\ben
\bnd
\bdh
\bh -
\b-o
\bou
\but
\bt /
\b/e
\bet
\btc
\bc/
\b/p
\bpo
\bos
\bst
\btf
\bfi
\bix
\bx/
\b/d
\bdh
\bh_
\b_1
\b10
\b02
\b24
\b4.
\b.p
\bpe
\bem
\bm -
\b-2
\b2 1
\b10
\b02
\b24
\b4
577 Support for elliptic curve cryptography is available with Postfix 2.6 and
578 OpenSSL 0.9.9 or later. To enable ephemeral elliptic curve Diffie-Hellman
579 (EECDH) key-exchange, set "smtpd_tls_eecdh_grade = strong" or
580 "smtpd_tls_eecdh_grade = ultra". The "ultra" setting is substantially more CPU
581 intensive, and "strong" is sufficiently secure for most situations.
585 /etc/postfix/main.cf:
586 smtpd_tls_dh1024_param_file = /etc/postfix/dh_1024.pem
587 smtpd_tls_dh512_param_file = /etc/postfix/dh_512.pem
589 smtpd_tls_eecdh_grade = strong
591 M
\bMi
\bis
\bsc
\bce
\bel
\bll
\bla
\ban
\bne
\beo
\bou
\bus
\bs s
\bse
\ber
\brv
\bve
\ber
\br c
\bco
\bon
\bnt
\btr
\bro
\bol
\bls
\bs
593 The smtpd_starttls_timeout parameter limits the time of Postfix SMTP server
594 write and read operations during TLS startup and shutdown handshake procedures.
598 /etc/postfix/main.cf:
599 smtpd_starttls_timeout = 300s
601 S
\bSM
\bMT
\bTP
\bP C
\bCl
\bli
\bie
\ben
\bnt
\bt s
\bsp
\bpe
\bec
\bci
\bif
\bfi
\bic
\bc s
\bse
\bet
\btt
\bti
\bin
\bng
\bgs
\bs
603 Topics covered in this section:
605 * TLS support in the LMTP delivery agent
606 * Client-side certificate and private key configuration
607 * Client-side TLS activity logging
608 * Client-side TLS session cache
609 * Client TLS limitations
610 * Configuring TLS in the SMTP/LMTP client
611 * Per-destination TLS policy
612 * Obsolete per-site TLS policy support
613 * Closing a DNS loophole with obsolete per-site TLS policies
614 * Discovering servers that support TLS
615 * Server certificate verification depth
616 * Client-side cipher controls
617 * Client-side SMTPS support
618 * Miscellaneous client controls
620 T
\bTL
\bLS
\bS s
\bsu
\bup
\bpp
\bpo
\bor
\brt
\bt i
\bin
\bn t
\bth
\bhe
\be L
\bLM
\bMT
\bTP
\bP d
\bde
\bel
\bli
\biv
\bve
\ber
\bry
\by a
\bag
\bge
\ben
\bnt
\bt
622 The smtp(8) and lmtp(8) delivery agents are implemented by a single dual-
623 purpose program. Specifically, all the TLS features described below apply
624 equally to SMTP and LMTP, after replacing the "smtp_" prefix of the each
625 parameter name with "lmtp_".
627 The Postfix LMTP delivery agent can communicate with LMTP servers listening on
628 UNIX-domain sockets. When server certificate verification is enabled and the
629 server is listening on a UNIX-domain socket, the $myhostname parameter is used
630 to set the TLS verification nexthop and hostname. Note, opportunistic
631 encryption of LMTP traffic over UNIX-domain sockets is futile. TLS is only
632 useful in this context when it is mandatory, typically to allow at least one of
633 the server or the client to authenticate the other. The "null" cipher grade may
634 be appropriate in this context, when available on both client and server. The
635 "null" ciphers provide authentication without encryption.
637 C
\bCl
\bli
\bie
\ben
\bnt
\bt-
\b-s
\bsi
\bid
\bde
\be c
\bce
\ber
\brt
\bti
\bif
\bfi
\bic
\bca
\bat
\bte
\be a
\ban
\bnd
\bd p
\bpr
\bri
\biv
\bva
\bat
\bte
\be k
\bke
\bey
\by c
\bco
\bon
\bnf
\bfi
\big
\bgu
\bur
\bra
\bat
\bti
\bio
\bon
\bn
639 Do not configure Postfix SMTP client certificates unless you m
\bmu
\bus
\bst
\bt present
640 client TLS certificates to one or more servers. Client certificates are not
641 usually needed, and can cause problems in configurations that work well without
642 them. The recommended setting is to let the defaults stand:
645 smtp_tls_dcert_file =
649 smtp_tls_eccert_file =
650 smtp_tls_eckey_file =
652 The best way to use the default settings is to comment out the above parameters
653 in main.cf if present.
655 During TLS startup negotiation the Postfix SMTP client may present a
656 certificate to the remote SMTP server. The Netscape client is rather clever
657 here and lets the user select between only those certificates that match CA
658 certificates offered by the remote SMTP server. As the Postfix SMTP client uses
659 the "SSL_connect()" function from the OpenSSL package, this is not possible and
660 we have to choose just one certificate. So for now the default is to use _no_
661 certificate and key unless one is explicitly specified here.
663 RSA, DSA and ECDSA (Postfix >= 2.6) certificates are supported. You can
664 configure all three at the same time, in which case the cipher used determines
665 which certificate is presented.
667 It is possible for the Postfix SMTP client to use the same key/certificate pair
668 as the Postfix SMTP server. If a certificate is to be presented, it must be in
669 "PEM" format. The private key must not be encrypted, meaning: it must be
670 accessible without password. Both parts (certificate and private key) may be in
673 To enable remote SMTP servers to verify the Postfix SMTP client certificate,
674 the issuing CA certificates must be made available to the server. You should
675 include the required certificates in the client certificate file, the client
676 certificate first, then the issuing CA(s) (bottom-up order).
678 Example: the certificate for "client.example.com" was issued by "intermediate
679 CA" which itself has a certificate issued by "root CA". Create the client.pem
682 % c
\bca
\bat
\bt c
\bcl
\bli
\bie
\ben
\bnt
\bt_
\b_c
\bce
\ber
\brt
\bt.
\b.p
\bpe
\bem
\bm i
\bin
\bnt
\bte
\ber
\brm
\bme
\bed
\bdi
\bia
\bat
\bte
\be_
\b_C
\bCA
\bA.
\b.p
\bpe
\bem
\bm >
\b> c
\bcl
\bli
\bie
\ben
\bnt
\bt.
\b.p
\bpe
\bem
\bm
684 A Postfix SMTP client certificate supplied here must be usable as SSL client
685 certificate and hence pass the "openssl verify -purpose sslclient ..." test.
687 A server that trusts the root CA has a local copy of the root CA certificate,
688 so it is not necessary to include the root CA certificate here. Leaving it out
689 of the "client.pem" file reduces the overhead of the TLS exchange.
691 If you want the Postfix SMTP client to accept remote SMTP server certificates
692 issued by these CAs, append the root certificate to $smtp_tls_CAfile or install
693 it in the $smtp_tls_CApath directory.
695 RSA key and certificate examples:
697 /etc/postfix/main.cf:
698 smtp_tls_cert_file = /etc/postfix/client.pem
699 smtp_tls_key_file = $smtp_tls_cert_file
701 Their DSA counterparts:
703 /etc/postfix/main.cf:
704 smtp_tls_dcert_file = /etc/postfix/client-dsa.pem
705 smtp_tls_dkey_file = $smtp_tls_dcert_file
707 Their ECDSA counterparts (Postfix >= 2.6 + OpenSSL >= 0.9.9):
709 /etc/postfix/main.cf:
710 smtp_tls_eccert_file = /etc/postfix/client-ecdsa.pem
711 smtp_tls_eckey_file = $smtp_tls_eccert_file
713 To verify a remote SMTP server certificate, the Postfix SMTP client needs to
714 trust the certificates of the issuing certification authorities. These
715 certificates in "pem" format can be stored in a single $smtp_tls_CAfile or in
716 multiple files, one CA per file in the $smtp_tls_CApath directory. If you use a
717 directory, don't forget to create the necessary "hash" links with:
719 # $
\b$O
\bOP
\bPE
\bEN
\bNS
\bSS
\bSL
\bL_
\b_H
\bHO
\bOM
\bME
\bE/
\b/b
\bbi
\bin
\bn/
\b/c
\bc_
\b_r
\bre
\beh
\bha
\bas
\bsh
\bh /
\b/p
\bpa
\bat
\bth
\bh/
\b/t
\bto
\bo/
\b/d
\bdi
\bir
\bre
\bec
\bct
\bto
\bor
\bry
\by
721 The $smtp_tls_CAfile contains the CA certificates of one or more trusted CAs.
722 The file is opened (with root privileges) before Postfix enters the optional
723 chroot jail and so need not be accessible from inside the chroot jail.
725 Additional trusted CAs can be specified via the $smtp_tls_CApath directory, in
726 which case the certificates are read (with $mail_owner privileges) from the
727 files in the directory when the information is needed. Thus, the
728 $smtp_tls_CApath directory needs to be accessible inside the optional chroot
731 The choice between $smtp_tls_CAfile and $smtp_tls_CApath is a space/time
732 tradeoff. If there are many trusted CAs, the cost of preloading them all into
733 memory may not pay off in reduced access time when the certificate is needed.
737 /etc/postfix/main.cf:
738 smtp_tls_CAfile = /etc/postfix/CAcert.pem
739 smtp_tls_CApath = /etc/postfix/certs
741 C
\bCl
\bli
\bie
\ben
\bnt
\bt-
\b-s
\bsi
\bid
\bde
\be T
\bTL
\bLS
\bS a
\bac
\bct
\bti
\biv
\bvi
\bit
\bty
\by l
\blo
\bog
\bgg
\bgi
\bin
\bng
\bg
743 To get additional information about Postfix SMTP client TLS activity you can
744 increase the loglevel from 0..4. Each logging level also includes the
745 information that is logged at a lower logging level.
747 0 Disable logging of TLS activity.
749 1 Log TLS handshake and certificate information.
751 2 Log levels during TLS negotiation.
753 3 Log hexadecimal and ASCII dump of TLS negotiation process
755 4 Log hexadecimal and ASCII dump of complete transmission after STARTTLS
759 /etc/postfix/main.cf:
760 smtp_tls_loglevel = 0
762 C
\bCl
\bli
\bie
\ben
\bnt
\bt-
\b-s
\bsi
\bid
\bde
\be T
\bTL
\bLS
\bS s
\bse
\bes
\bss
\bsi
\bio
\bon
\bn c
\bca
\bac
\bch
\bhe
\be
764 The remote SMTP server and the Postfix SMTP client negotiate a session, which
765 takes some computer time and network bandwidth. By default, this session
766 information is cached only in the smtp(8) process actually using this session
767 and is lost when the process terminates. To share the session information
768 between multiple smtp(8) processes, a persistent session cache can be used. You
769 can specify any database type that can store objects of several kbytes and that
770 supports the sequence operator. DBM databases are not suitable because they can
771 only store small objects. The cache is maintained by the tlsmgr(8) process, so
772 there is no problem with concurrent access. Session caching is highly
773 recommended, because the cost of repeatedly negotiating TLS session keys is
774 high. Future Postfix SMTP servers may limit the number of sessions that a
775 client is allowed to negotiate per unit time.
779 /etc/postfix/main.cf:
780 smtp_tls_session_cache_database = btree:/var/db/postfix/smtp_scache
782 Note: as of version 2.5, Postfix no longer uses root privileges when opening
783 this file. The file should now be stored under the Postfix-owned
784 data_directory. As a migration aid, an attempt to open the file under a non-
785 Postfix directory is redirected to the Postfix-owned data_directory, and a
788 Cached Postfix SMTP client session information expires after a certain amount
789 of time. Postfix/TLS does not use the OpenSSL default of 300s, but a longer
790 time of 3600s (=1 hour). RFC 2246 recommends a maximum of 24 hours.
794 /etc/postfix/main.cf:
795 smtp_tls_session_cache_timeout = 3600s
797 C
\bCl
\bli
\bie
\ben
\bnt
\bt T
\bTL
\bLS
\bS l
\bli
\bim
\bmi
\bit
\bta
\bat
\bti
\bio
\bon
\bns
\bs
799 The security properties of TLS communication channels are application specific.
800 While the TLS protocol can provide a confidential, tamper-resistant, mutually
801 authenticated channel between client and server, not all of these security
802 features are applicable to every communication.
804 For example, while mutual TLS authentication between browsers and web servers
805 is possible, it is not practical, or even useful, for web-servers that serve
806 the public to verify the identity of every potential user. In practice, most
807 HTTPS transactions are asymmetric: the browser verifies the HTTPS server's
808 identity, but the user remains anonymous. Much of the security policy is up to
809 the client. If the client chooses to not verify the server's name, the server
810 is not aware of this. There are many interesting browser security topics, but
811 we shall not dwell on them here. Rather, our goal is to understand the security
812 features of TLS in conjunction with SMTP.
814 An important SMTP-specific observation is that a public MX host is even more at
815 the mercy of the SMTP client than is an HTTPS server. Not only can it not
816 enforce due care in the client's use of TLS, but it cannot even enforce the use
817 of TLS, because TLS support in SMTP clients is still the exception rather than
818 the rule. One cannot, in practice, limit access to one's MX hosts to just TLS-
819 enabled clients. Such a policy would result in a vast reduction in one's
820 ability to communicate by email with the world at large.
822 One may be tempted to try enforcing TLS for mail from specific sending
823 organizations, but this, too, runs into obstacles. One such obstacle is that we
824 don't know who is (allegedly) sending mail until we see the "MAIL FROM:" SMTP
825 command, and at that point, if TLS is not already in use, a potentially
826 sensitive sender address (and with SMTP PIPELINING one or more of the
827 recipients) has (have) already been leaked in the clear. Another obstacle is
828 that mail from the sender to the recipient may be forwarded, and the forwarding
829 organization may not have any security arrangements with the final destination.
830 Bounces also need to be protected. These can only be identified by the IP
831 address and HELO name of the connecting client, and it is difficult to keep
832 track of all the potential IP addresses or HELO names of the outbound email
833 servers of the sending organization.
835 Consequently, TLS security for mail delivery to public MX hosts is almost
836 entirely the client's responsibility. The server is largely a passive enabler
837 of TLS security, the rest is up to the client. While the server has a greater
838 opportunity to mandate client security policy when it is a dedicated MSA that
839 only handles outbound mail from trusted clients, below we focus on the client
842 On the SMTP client, there are further complications. When delivering mail to a
843 given domain, in contrast to HTTPS, one rarely uses the domain name directly as
844 the target host of the SMTP session. More typically, one uses MX lookups -
845 these are usually unauthenticated - to obtain the domain's SMTP server hostname
846 (s). When, as is current practice, the client verifies the insecurely obtained
847 MX hostname, it is subject to a DNS man-in-the-middle attack.
849 If clients instead attempted to verify the recipient domain name, an SMTP
850 server for multiple domains would need to list all its email domain names in
851 its certificate, and generate a new certificate each time a new domain were
852 added. At least some CAs set fairly low limits (20 for one prominent CA) on the
853 number of names that server certificates can contain. This approach is not
854 consistent with current practice and does not scale.
856 It is regrettably the case that TLS secure-channels (fully authenticated and
857 immune to man-in-the-middle attacks) impose constraints on the sending and
858 receiving sites that preclude ubiquitous deployment. One needs to manually
859 configure this type of security for each destination domain, and in many cases
860 implement non-default TLS policy table entries for additional domains hosted at
861 a common secured destination. With Postfix 2.3, we make secure-channel
862 configurations substantially easier to configure, but they will never be the
863 norm. For the generic domain with which you have made no specific security
864 arrangements, this security level is not a good fit.
866 Given that strong authentication is not generally possible, and that verifiable
867 certificates cost time and money, many servers that implement TLS use self-
868 signed certificates or private CAs. This further limits the applicability of
869 verified TLS on the public Internet.
871 Historical note: while the documentation of these issues and many of the
872 related features are new with Postfix 2.3, the issue was well understood before
873 Postfix 1.0, when Lutz Jänicke was designing the first unofficial Postfix TLS
874 patch. See his original post http://www.imc.org/ietf-apps-tls/mail-archive/
875 msg00304.html and the first response http://www.imc.org/ietf-apps-tls/mail-
876 archive/msg00305.html. The problem is not even unique to SMTP or even TLS,
877 similar issues exist for secure connections via aliases for HTTPS and Kerberos.
878 SMTP merely uses indirect naming (via MX records) more frequently.
880 C
\bCo
\bon
\bnf
\bfi
\big
\bgu
\bur
\bri
\bin
\bng
\bg T
\bTL
\bLS
\bS i
\bin
\bn t
\bth
\bhe
\be S
\bSM
\bMT
\bTP
\bP/
\b/L
\bLM
\bMT
\bTP
\bP c
\bcl
\bli
\bie
\ben
\bnt
\bt
882 Similar to the Postfix SMTP server, the Postfix SMTP/LMTP client implements
883 multiple TLS security levels. These levels are described in more detail in the
884 sections that follow.
890 e
\ben
\bnc
\bcr
\bry
\byp
\bpt
\bt
891 Mandatory TLS encryption.
892 f
\bfi
\bin
\bng
\bge
\ber
\brp
\bpr
\bri
\bin
\bnt
\bt
893 Certificate fingerprint verification.
894 v
\bve
\ber
\bri
\bif
\bfy
\by
895 Mandatory server certificate verification.
896 s
\bse
\bec
\bcu
\bur
\bre
\be
899 N
\bNo
\bo T
\bTL
\bLS
\bS e
\ben
\bnc
\bcr
\bry
\byp
\bpt
\bti
\bio
\bon
\bn
901 At the "none" TLS security level, TLS encryption is disabled. This is the
902 default security level. With Postfix 2.3 and later, it can be configured
903 explicitly by setting "smtp_tls_security_level = none".
905 With Postfix 2.2 and earlier, or when smtp_tls_security_level is set to its
906 default (backwards compatible) empty value, the appropriate configuration
907 settings are "smtp_use_tls = no" and "smtp_enforce_tls = no". With either
908 approach, TLS is not used even if supported by the server. For LMTP, use the
909 corresponding "lmtp_" parameters.
911 Per destination settings may override this default setting, in which case TLS
912 is used selectively, only with destinations explicitly configured for TLS.
914 You can disable TLS for a subset of destinations, while leaving it enabled for
915 the rest. With the Postfix 2.3 and later TLS policy table, specify the "none"
916 security level. With the obsolete per-site table, specify the "NONE" keyword.
918 O
\bOp
\bpp
\bpo
\bor
\brt
\btu
\bun
\bni
\bis
\bst
\bti
\bic
\bc T
\bTL
\bLS
\bS
920 At the "may" TLS security level, TLS encryption is opportunistic. The SMTP
921 transaction is encrypted if the STARTTLS ESMTP feature is supported by the
922 server. Otherwise, messages are sent in the clear. With Postfix 2.3 and later,
923 opportunistic TLS can be configured by setting "smtp_tls_security_level = may".
925 Since sending in the clear is acceptable, demanding stronger than default TLS
926 security mostly reduces inter-operability. If you must restrict TLS protocol or
927 cipher selection even with opportunistic TLS, the "smtp_tls_ciphers" and
928 "smtp_tls_protocols" configuration parameters (Postfix >= 2.6) provide control
929 over the protocols and cipher grade used with opportunistic TLS. With earlier
930 releases the opportunistic TLS cipher grade is always "export" and no protocols
933 With Postfix 2.2 and earlier, or when smtp_tls_security_level is set to its
934 default (backwards compatible) empty value, the appropriate configuration
935 settings are "smtp_use_tls = yes" and "smtp_enforce_tls = no". For LMTP use the
936 corresponding "lmtp_" parameters.
938 With opportunistic TLS, mail delivery continues even if the server certificate
939 is untrusted or bears the wrong name. Starting with Postfix 2.3, when the TLS
940 handshake fails for an opportunistic TLS session, rather than give up on mail
941 delivery, the transaction is retried with TLS disabled. Trying an unencrypted
942 connection makes it possible to deliver mail to sites with non-interoperable
943 server TLS implementations.
945 Opportunistic encryption is never used for LMTP over UNIX-domain sockets. The
946 communications channel is already confidential without TLS, so the only
947 potential benefit of TLS is authentication. Do not configure opportunistic TLS
948 for LMTP deliveries over UNIX-domain sockets. Only configure TLS for LMTP over
949 UNIX-domain sockets at the encrypt security level or higher. Attempts to
950 configure opportunistic encryption of LMTP sessions will be ignored with a
951 warning written to the mail logs.
953 You can enable opportunistic TLS just for selected destinations. With the
954 Postfix 2.3 and later TLS policy table, specify the "may" security level. With
955 the obsolete per-site table, specify the "MAY" keyword.
957 This is the most common security level for TLS protected SMTP sessions,
958 stronger security is not generally available and, if needed, is typically only
959 configured on a per-destination basis. See the section on TLS limitations
964 /etc/postfix/main.cf:
965 smtp_tls_security_level = may
969 /etc/postfix/main.cf:
971 smtp_enforce_tls = no
973 M
\bMa
\ban
\bnd
\bda
\bat
\bto
\bor
\bry
\by T
\bTL
\bLS
\bS e
\ben
\bnc
\bcr
\bry
\byp
\bpt
\bti
\bio
\bon
\bn
975 At the "encrypt" TLS security level, messages are sent only over TLS encrypted
976 sessions. The SMTP transaction is aborted unless the STARTTLS ESMTP feature is
977 supported by the remote SMTP server. If no suitable servers are found, the
978 message will be deferred. With Postfix 2.3 and later, mandatory TLS encryption
979 can be configured by setting "smtp_tls_security_level = encrypt". Even though
980 TLS encryption is always used, mail delivery continues even if the server
981 certificate is untrusted or bears the wrong name.
983 At this security level and higher, the smtp_tls_mandatory_protocols and
984 smtp_tls_mandatory_ciphers configuration parameters determine the list of
985 sufficiently secure SSL protocol versions and the minimum cipher strength. If
986 the protocol or cipher requirements are not met, the mail transaction is
987 aborted. The documentation for these parameters includes useful
988 interoperability and security guidelines.
990 With Postfix 2.2 and earlier, or when smtp_tls_security_level is set to its
991 default (backwards compatible) empty value, the appropriate configuration
992 settings are "smtp_enforce_tls = yes" and "smtp_tls_enforce_peername = no". For
993 LMTP use the corresponding "lmtp_" parameters.
995 Despite the potential for eliminating passive eavesdropping attacks, mandatory
996 TLS encryption is not viable as a default security level for mail delivery to
997 the public Internet. Most MX hosts do not support TLS at all, and some of those
998 that do have broken implementations. On a host that delivers mail to the
999 Internet, you should not configure mandatory TLS encryption as the default
1002 You can enable mandatory TLS encryption just for specific destinations. With
1003 the Postfix 2.3 and later TLS policy table, specify the "encrypt" security
1004 level. With the obsolete per-site table, specify the "MUST_NOPEERMATCH"
1005 keyword. While the obsolete approach still works with Postfix 2.3, it is
1006 strongly discouraged: users of Postfix 2.3 and later should use the new TLS
1011 In the example below, traffic to example.com and its sub-domains via the
1012 corresponding MX hosts always uses TLS. The protocol version will be "SSLv3" or
1013 "TLSv1" (the default setting of smtp_tls_mandatory_protocols excludes "SSLv2").
1014 Only high or medium strength (i.e. 128 bit or better) ciphers will be used by
1015 default for all "encrypt" security level sessions.
1017 /etc/postfix/main.cf:
1018 smtp_tls_policy_maps = hash:/etc/postfix/tls_policy
1020 /etc/postfix/tls_policy:
1022 .example.com encrypt
1024 Postfix 2.2 syntax (no support for sub-domains without resorting to regexp
1025 tables). With Postfix 2.3 and later, do not use the obsolete per-site table.
1027 /etc/postfix/main.cf:
1028 smtp_tls_per_site = hash:/etc/postfix/tls_per_site
1030 /etc/postfix/tls_per_site:
1031 example.com MUST_NOPEERMATCH
1033 In the next example, secure message submission is configured via the MSA "
1034 [example.net]:587". TLS sessions are encrypted without authentication, because
1035 this MSA does not possess an acceptable certificate. This MSA is known to be
1036 capable of "TLSv1" and "high" grade ciphers, so these are selected via the
1039 N
\bNo
\bot
\bte
\be:
\b: the policy table lookup key is the verbatim next-hop specification from
1040 the recipient domain, transport(5) table or relayhost parameter, with any
1041 enclosing square brackets and optional port. Take care to be consistent: the
1042 suffixes ":smtp" or ":25" or no port suffix result in different policy table
1043 lookup keys, even though they are functionally equivalent nexthop
1044 specifications. Use at most one of these forms for all destinations. Below, the
1045 policy table has multiple keys, just in case the transport table entries are
1046 not specified consistently.
1048 /etc/postfix/main.cf:
1049 smtp_tls_policy_maps = hash:/etc/postfix/tls_policy
1052 submission 587/tcp msa # mail message
1055 /etc/postfix/tls_policy:
1056 [example.net]:587 encrypt protocols=TLSv1 ciphers=high
1057 [example.net]:msa encrypt protocols=TLSv1 ciphers=high
1058 [example.net]:submission encrypt protocols=TLSv1 ciphers=high
1062 N
\bNo
\bot
\bte
\be:
\b: Avoid policy lookups with the bare hostname (for example, "example.net").
1063 Instead, use the destination (for example, "[example.net]:587"), as the per-
1064 site table lookup key (a recipient domain or MX-enabled transport nexthop with
1065 no port suffix may look like a bare hostname, but is still a suitable
1066 destination). With Postfix 2.3 and later, do not use the obsolete per-site
1067 table; use the new policy table instead.
1069 /etc/postfix/main.cf:
1070 smtp_tls_per_site = hash:/etc/postfix/tls_per_site
1072 /etc/postfix/tls_per_site:
1073 [example.net]:587 MUST_NOPEERMATCH
1075 C
\bCe
\ber
\brt
\bti
\bif
\bfi
\bic
\bca
\bat
\bte
\be f
\bfi
\bin
\bng
\bge
\ber
\brp
\bpr
\bri
\bin
\bnt
\bt v
\bve
\ber
\bri
\bif
\bfi
\bic
\bca
\bat
\bti
\bio
\bon
\bn
1077 Certificate fingerprint verification is available with Postfix 2.5 and later.
1078 At this security level ("smtp_tls_security_level = fingerprint"), no trusted
1079 certificate authorities are used or required. The certificate trust chain,
1080 expiration date, ... are not checked. Instead, the
1081 smtp_tls_fingerprint_cert_match parameter or the "match" attribute in the
1082 policy table lists the valid "fingerprints" of the remote SMTP server
1085 If certificate fingerprints are exchanged securely, this is the strongest, and
1086 least scalable security level. The administrator needs to securely collect the
1087 fingerprints of the X.509 certificates of each peer server, store them into a
1088 local file, and update this local file whenever the peer server's public
1089 certificate changes. This may be feasible for an SMTP "VPN" connecting a small
1090 number of branch offices over the Internet, or for secure connections to a
1091 central mail hub. It works poorly if the remote SMTP server is managed by a
1092 third party, and its public certificate changes periodically without prior
1093 coordination with the verifying site.
1095 The digest algorithm used to calculate the fingerprint is selected by the
1096 s
\bsm
\bmt
\btp
\bp_
\b_t
\btl
\bls
\bs_
\b_f
\bfi
\bin
\bng
\bge
\ber
\brp
\bpr
\bri
\bin
\bnt
\bt_
\b_d
\bdi
\big
\bge
\bes
\bst
\bt parameter. In the policy table multiple
1097 fingerprints can be combined with a "|" delimiter in a single match attribute,
1098 or multiple match attributes can be employed. The ":" character is not used as
1099 a delimiter as it occurs between each pair of fingerprint (hexadecimal) digits.
1101 Example: fingerprint TLS security with an internal mailhub. Two matching
1102 fingerprints are listed. The relayhost may be multiple physical hosts behind a
1103 load-balancer, each with its own private/public key and self-signed
1104 certificate. Alternatively, a single relayhost may be in the process of
1105 switching from one set of private/public keys to another, and both keys are
1106 trusted just prior to the transition.
1108 relayhost = [mailhub.example.com]
1109 smtp_tls_security_level = fingerprint
1110 smtp_tls_fingerprint_digest = md5
1111 smtp_tls_fingerprint_cert_match =
1112 3D:95:34:51:24:66:33:B9:D2:40:99:C0:C1:17:0B:D1
1113 EC:3B:2D:B0:5B:B1:FB:6D:20:A3:9D:72:F6:8D:12:35
1115 Example: Certificate fingerprint verification with selected destinations. As in
1116 the example above, we show two matching fingerprints:
1118 /etc/postfix/main.cf:
1119 smtp_tls_policy_maps = hash:/etc/postfix/tls_policy
1120 smtp_tls_fingerprint_digest = md5
1122 /etc/postfix/tls_policy:
1123 example.com fingerprint
1124 match=3D:95:34:51:24:66:33:B9:D2:40:99:C0:C1:17:0B:D1
1125 match=EC:3B:2D:B0:5B:B1:FB:6D:20:A3:9D:72:F6:8D:12:35
1127 M
\bMa
\ban
\bnd
\bda
\bat
\bto
\bor
\bry
\by s
\bse
\ber
\brv
\bve
\ber
\br c
\bce
\ber
\brt
\bti
\bif
\bfi
\bic
\bca
\bat
\bte
\be v
\bve
\ber
\bri
\bif
\bfi
\bic
\bca
\bat
\bti
\bio
\bon
\bn
1129 At the "verify" TLS security level, messages are sent only over TLS encrypted
1130 sessions if the remote SMTP server certificate is valid (not expired or
1131 revoked, and signed by a trusted certificate authority) and where the server
1132 certificate name matches a known pattern. Mandatory server certificate
1133 verification can be configured by setting "smtp_tls_security_level = verify".
1134 The smtp_tls_verify_cert_match parameter can override the default "hostname"
1135 certificate name matching strategy. Fine-tuning the matching strategy is
1136 generally only appropriate for secure-channel destinations.
1138 With Postfix 2.2 and earlier, or when smtp_tls_security_level is set to its
1139 default (backwards compatible) empty value, the appropriate configuration
1140 settings are "smtp_enforce_tls = yes" and "smtp_tls_enforce_peername = yes".
1141 For LMTP use the corresponding "lmtp_" parameters.
1143 If the server certificate chain is trusted (see smtp_tls_CAfile and
1144 smtp_tls_CApath), any DNS names in the SubjectAlternativeName certificate
1145 extension are used to verify the remote SMTP server name. If no DNS names are
1146 specified, the certificate CommonName is checked. If you want mandatory
1147 encryption without server certificate verification, see above.
1149 Despite the potential for eliminating "man-in-the-middle" and other attacks,
1150 mandatory certificate trust chain and subject name verification is not viable
1151 as a default Internet mail delivery policy. Most MX hosts do not support TLS at
1152 all, and a significant portion of TLS enabled MTAs use self-signed
1153 certificates, or certificates that are signed by a private certificate
1154 authority. On a machine that delivers mail to the Internet, you should not
1155 configure mandatory server certificate verification as a default policy.
1157 Mandatory server certificate verification as a default security level may be
1158 appropriate if you know that you will only connect to servers that support RFC
1159 2487 and that present verifiable server certificates. An example would be a
1160 client that sends all email to a central mailhub that offers the necessary
1161 STARTTLS support. In such cases, you can often use a secure-channel
1162 configuration instead.
1164 You can enable mandatory server certificate verification just for specific
1165 destinations. With the Postfix 2.3 and later TLS policy table, specify the
1166 "verify" security level. With the obsolete per-site table, specify the "MUST"
1167 keyword. While the obsolete approach still works with Postfix 2.3, it is
1168 strongly discouraged: users of Postfix 2.3 and later should use the new TLS
1173 In this example, the Postfix SMTP client encrypts all traffic to the
1174 example.com domain. The peer hostname is verified, but verification is
1175 vulnerable to DNS response forgery. Mail transmission to example.com recipients
1176 uses "high" grade ciphers.
1178 /etc/postfix/main.cf:
1179 indexed = ${default_database_type}:${config_directory}/
1180 smtp_tls_CAfile = ${config_directory}/CAfile.pem
1181 smtp_tls_policy_maps = ${indexed}tls_policy
1183 /etc/postfix/tls_policy:
1184 example.com verify ciphers=high
1188 /etc/postfix/main.cf:
1189 indexed = ${default_database_type}:${config_directory}/
1190 smtp_tls_CAfile = ${config_directory}/CAfile.pem
1191 smtp_tls_per_site = ${indexed}tls_per_site
1193 /etc/postfix/tls_per_site:
1196 S
\bSe
\bec
\bcu
\bur
\bre
\be s
\bse
\ber
\brv
\bve
\ber
\br c
\bce
\ber
\brt
\bti
\bif
\bfi
\bic
\bca
\bat
\bte
\be v
\bve
\ber
\bri
\bif
\bfi
\bic
\bca
\bat
\bti
\bio
\bon
\bn
1198 At the secure TLS security level, messages are sent only over secure-channel
1199 TLS sessions where DNS forgery resistant server certificate verification
1200 succeeds. If no suitable servers are found, the message will be deferred. With
1201 Postfix 2.3 and later, secure-channels can be configured by setting
1202 "smtp_tls_security_level = secure". The smtp_tls_secure_cert_match parameter
1203 can override the default "nexthop, dot-nexthop" certificate match strategy.
1205 With Postfix 2.2 and earlier, or when smtp_tls_security_level is set to its
1206 default (backwards compatible) empty value, the appropriate configuration
1207 settings are "smtp_enforce_tls = yes" and "smtp_tls_enforce_peername = yes"
1208 with additional settings to harden peer certificate verification against forged
1209 DNS data. For LMTP, use the corresponding "lmtp_" parameters.
1211 If the server certificate chain is trusted (see smtp_tls_CAfile and
1212 smtp_tls_CApath), any DNS names in the SubjectAlternativeName certificate
1213 extension are used to verify the remote SMTP server name. If no DNS names are
1214 specified, the CommonName is checked. If you want mandatory encryption without
1215 server certificate verification, see above.
1217 Despite the potential for eliminating "man-in-the-middle" and other attacks,
1218 mandatory secure server certificate verification is not viable as a default
1219 Internet mail delivery policy. Most MX hosts do not support TLS at all, and a
1220 significant portion of TLS enabled MTAs use self-signed certificates, or
1221 certificates that are signed by a private certificate authority. On a machine
1222 that delivers mail to the Internet, you should not configure secure TLS
1223 verification as a default policy.
1225 Mandatory secure server certificate verification as a default security level
1226 may be appropriate if you know that you will only connect to servers that
1227 support RFC 2487 and that present verifiable server certificates. An example
1228 would be a client that sends all email to a central mailhub that offers the
1229 necessary STARTTLS support.
1231 You can enable secure TLS verification just for specific destinations. With the
1232 Postfix 2.3 and later TLS policy table, specify the "secure" security level.
1233 With the obsolete per-site table, specify the "MUST" keyword and harden the
1234 certificate verification against DNS forgery. While the obsolete approach still
1235 works with Postfix 2.3, it is strongly discouraged: users of Postfix 2.3 and
1236 later should use the new TLS policy settings.
1240 Secure-channel TLS without transport(5) table overrides:
1242 The Postfix SMTP client will encrypt all traffic and verify the destination
1243 name immune from forged DNS responses. MX lookups are still used to find the
1244 hostnames of the SMTP servers for example.com, but these hostnames are not used
1245 when checking the names in the server certificate(s). Rather, the requirement
1246 is that the MX hosts for example.com have trusted certificates with a subject
1247 name of example.com or a sub-domain, see the documentation for the
1248 smtp_tls_secure_cert_match parameter.
1250 The related domains example.co.uk and example.co.jp are hosted on the same MX
1251 hosts as the primary example.com domain, and traffic to these is secured by
1252 verifying the primary example.com domain in the server certificates. This frees
1253 the server administrator from needing the CA to sign certificates that list all
1254 the secondary domains. The downside is that clients that want secure channels
1255 to the secondary domains need explicit TLS policy table entries.
1257 Note, there are two ways to handle related domains. The first is to use the
1258 default routing for each domain, but add policy table entries to override the
1259 expected certificate subject name. The second is to override the next-hop in
1260 the transport table, and use a single policy table entry for the common
1261 nexthop. We choose the first approach, because it works better when domain
1262 ownership changes. With the second approach we securely deliver mail to the
1263 wrong destination, with the first approach, authentication fails and mail stays
1264 in the local queue, the first approach is more appropriate in most cases.
1266 /etc/postfix/main.cf:
1267 smtp_tls_CAfile = /etc/postfix/CAfile.pem
1268 smtp_tls_policy_maps = hash:/etc/postfix/tls_policy
1270 /etc/postfix/transport:
1272 /etc/postfix/tls_policy:
1274 example.co.uk secure match=example.com:.example.com
1275 example.co.jp secure match=example.com:.example.com
1277 Secure-channel TLS with transport(5) table overrides:
1279 In this case traffic to example.com and its related domains is sent to a single
1280 logical gateway (to avoid a single point of failure, its name may resolve to
1281 one or more load-balancer addresses, or to the combined addresses of multiple
1282 physical hosts). All the physical hosts reachable via the gateway's IP
1283 addresses have the logical gateway name listed in their certificates. This
1284 secure-channel configuration can also be implemented via a hardened variant of
1285 the MUST policy in the obsolete per-site table. As stated above, this approach
1286 has the potential to mis-deliver email if the related domains change hands.
1288 /etc/postfix/main.cf:
1289 smtp_tls_CAfile = /etc/postfix/CAfile.pem
1290 transport_maps = hash:/etc/postfix/transport
1291 smtp_tls_policy_maps = hash:/etc/postfix/tls_policy
1293 /etc/postfix/transport:
1294 example.com smtp:[tls.example.com]
1295 example.co.uk smtp:[tls.example.com]
1296 example.co.jp smtp:[tls.example.com]
1298 /etc/postfix/tls_policy:
1299 [tls.example.com] secure match=tls.example.com
1301 Postfix 2.2.9 and later syntax:
1303 N
\bNo
\bot
\bte
\be:
\b: Avoid policy lookups with the bare hostname (for example,
1304 "tls.example.com"). Instead, use the destination (for example, "
1305 [tls.example.com]") as the per-site table lookup key (a recipient domain or MX-
1306 enabled transport nexthop with no port suffix may look like a bare hostname,
1307 but is still a suitable destination). With Postfix 2.3 and later, do not use
1308 the obsolete per-site table; use the new policy table instead.
1310 /etc/postfix/main.cf:
1311 smtp_cname_overrides_servername = no
1312 smtp_tls_CAfile = /etc/postfix/CAfile.pem
1313 transport_maps = hash:/etc/postfix/transport
1314 smtp_tls_per_site = hash:/etc/postfix/tls_per_site
1316 /etc/postfix/transport:
1317 example.com smtp:[tls.example.com]
1318 example.co.uk smtp:[tls.example.com]
1319 example.co.jp smtp:[tls.example.com]
1321 /etc/postfix/tls_per_site:
1322 [tls.example.com] MUST
1324 T
\bTL
\bLS
\bS p
\bpo
\bol
\bli
\bic
\bcy
\by t
\bta
\bab
\bbl
\ble
\be
1326 The current TLS policy table was introduced with Postfix 2.3. For earlier
1327 releases, read the description of the obsolete Postfix 2.2 per-site table.
1329 A small fraction of servers offer STARTTLS but the negotiation consistently
1330 fails. With Postfix 2.3, so long as encryption is not enforced, the delivery is
1331 immediately retried with TLS disabled. You no longer need to explicitly disable
1332 TLS for the problem destinations. As soon as their TLS software or
1333 configuration is repaired, encryption will be used.
1335 The new policy table is specified via the smtp_tls_policy_maps parameter. This
1336 lists optional lookup tables with the Postfix SMTP client TLS security policy
1337 by next-hop destination. When $smtp_tls_policy_maps is not empty, the obsolete
1338 smtp_tls_per_site parameter is ignored (a warning is written to the logs if
1339 both parameter values are non-empty).
1341 The TLS policy table is indexed by the full next-hop destination, which is
1342 either the recipient domain, or the verbatim next-hop specified in the
1343 transport table, $local_transport, $virtual_transport, $relay_transport or
1344 $default_transport. This includes any enclosing square brackets and any non-
1345 default destination server port suffix. The LMTP socket type prefix (inet: or
1346 unix:) is not included in the lookup key.
1348 Only the next-hop domain, or $myhostname with LMTP over UNIX-domain sockets, is
1349 used as the nexthop name for certificate verification. The port and any
1350 enclosing square brackets are used in the table lookup key, but are not used
1351 for server name verification.
1353 When the lookup key is a domain name without enclosing square brackets or any :
1354 port suffix (typically the recipient domain), and the full domain is not found
1355 in the table, just as with the transport(5) table, the parent domain starting
1356 with a leading "." is matched recursively. This allows one to specify a
1357 security policy for a recipient domain and all its sub-domains.
1359 The lookup result is a security level, followed by an optional list of
1360 whitespace and/or comma separated name=value attributes that override related
1361 main.cf settings. The TLS security levels are described above. Below, we
1362 describe the corresponding table syntax:
1365 No TLS. No additional attributes are supported at this level.
1367 Opportunistic TLS. The optional "ciphers", "exclude" and "protocols"
1368 attributes (available for opportunistic TLS with Postfix >= 2.6) override
1369 the "smtp_tls_ciphers", "smtp_tls_exclude_ciphers" and "smtp_tls_protocols"
1370 configuration parameters.
1371 e
\ben
\bnc
\bcr
\bry
\byp
\bpt
\bt
1372 Mandatory encryption. Mail is delivered only if the remote SMTP server
1373 offers STARTTLS and the TLS handshake succeeds. At this level and higher,
1374 the optional "protocols" attribute overrides the main.cf
1375 smtp_tls_mandatory_protocols parameter, the optional "ciphers" attribute
1376 overrides the main.cf smtp_tls_mandatory_ciphers parameter, and the
1377 optional "exclude" attribute (Postfix >= 2.6) overrides the main.cf
1378 smtp_tls_mandatory_exclude_ciphers parameter.
1379 f
\bfi
\bin
\bng
\bge
\ber
\brp
\bpr
\bri
\bin
\bnt
\bt
1380 Certificate fingerprint verification. Available with Postfix 2.5 and later.
1381 At this security level, there are no trusted certificate authorities. The
1382 certificate trust chain, expiration date, ... are not checked. Instead, the
1383 optional m
\bma
\bat
\btc
\bch
\bh attribute, or else the main.cf
1384 s
\bsm
\bmt
\btp
\bp_
\b_t
\btl
\bls
\bs_
\b_f
\bfi
\bin
\bng
\bge
\ber
\brp
\bpr
\bri
\bin
\bnt
\bt_
\b_c
\bce
\ber
\brt
\bt_
\b_m
\bma
\bat
\btc
\bch
\bh parameter, lists the valid fingerprints of
1385 the server certificate. The digest algorithm used to calculate fingerprints
1386 is selected by the s
\bsm
\bmt
\btp
\bp_
\b_t
\btl
\bls
\bs_
\b_f
\bfi
\bin
\bng
\bge
\ber
\brp
\bpr
\bri
\bin
\bnt
\bt_
\b_d
\bdi
\big
\bge
\bes
\bst
\bt parameter. Multiple
1387 fingerprints can be combined with a "|" delimiter in a single match
1388 attribute, or multiple match attributes can be employed. The ":" character
1389 is not used as a delimiter as it occurs between each pair of fingerprint
1390 (hexadecimal) digits.
1391 v
\bve
\ber
\bri
\bif
\bfy
\by
1392 Mandatory server certificate verification. Mail is delivered only if the
1393 TLS handshake succeeds, if the remote SMTP server certificate can be
1394 validated (not expired or revoked, and signed by a trusted certificate
1395 authority), and if the server certificate name matches the optional "match"
1396 attribute (or the main.cf smtp_tls_verify_cert_match parameter value when
1397 no optional "match" attribute is specified).
1398 s
\bse
\bec
\bcu
\bur
\bre
\be
1399 Secure certificate verification. Mail is delivered only if the TLS
1400 handshake succeeds, if the remote SMTP server certificate can be validated
1401 (not expired or revoked, and signed by a trusted certificate authority),
1402 and if the server certificate name matches the optional "match" attribute
1403 (or the main.cf smtp_tls_secure_cert_match parameter value when no optional
1404 "match" attribute is specified).
1407 * The "match" attribute is especially useful to verify TLS certificates for
1408 domains that are hosted on a shared server. In that case, specify "match"
1409 rules for the shared server's name. While secure verification can also be
1410 achieved with manual routing overrides in Postfix transport(5) tables, that
1411 approach can deliver mail to the wrong host when domains are assigned to
1412 new gateway hosts. The "match" attribute approach avoids the problems of
1413 manual routing overrides; mail is deferred if verification of a new MX host
1416 * When a policy table entry specifies multiple match patterns, multiple match
1417 strategies, or multiple protocols, these must be separated by colons.
1419 * The "exclude" attribute (Postfix >= 2.6) is used to disable ciphers that
1420 cause handshake failures with a specific mandatory TLS destination, without
1421 disabling the ciphers for all mandatory destinations. Alternatively, you
1422 can exclude ciphers that cause issues with multiple remote servers in
1423 main.cf, and selectively enable them on a per-destination basis in the
1424 policy table by setting a shorter or empty exclusion list. The per-
1425 destination "exclude" list preempts both the opportunistic and mandatory
1426 security level exclusions, so that all excluded ciphers can be enabled for
1427 known-good destinations. For non-mandatory TLS destinations that exhibit
1428 cipher-specific problems, Postfix will fall back to plain-text delivery. If
1429 plain-text is not acceptable make TLS mandatory and exclude the problem
1434 /etc/postfix/main.cf:
1435 smtp_tls_policy_maps = hash:/etc/postfix/tls_policy
1436 # Postfix 2.5 and later
1437 smtp_tls_fingerprint_digest = md5
1438 /etc/postfix/tls_policy:
1441 example.gov encrypt protocols=SSLv3:TLSv1 ciphers=high
1443 match=hostname:dot-nexthop protocols=SSLv3:TLSv1 ciphers=high
1445 .example.net secure match=.example.net:example.net
1446 [mail.example.org]:587 secure match=nexthop
1447 # Postfix 2.5 and later
1448 [thumb.example.org] fingerprint
1449 match=EC:3B:2D:B0:5B:B1:FB:6D:20:A3:9D:72:F6:8D:12:35
1450 match=3D:95:34:51:24:66:33:B9:D2:40:99:C0:C1:17:0B:D1
1451 # Postfix 2.6 and later
1452 example.info may protocols=!SSLv2 ciphers=medium
1455 N
\bNo
\bot
\bte
\be:
\b: The "hostname" strategy if listed in a non-default setting of
1456 smtp_tls_secure_cert_match or in the "match" attribute in the policy table can
1457 render the "secure" level vulnerable to DNS forgery. Do not use the "hostname"
1458 strategy for secure-channel configurations in environments where DNS security
1461 O
\bOb
\bbs
\bso
\bol
\ble
\bet
\bte
\be p
\bpe
\ber
\br-
\b-s
\bsi
\bit
\bte
\be T
\bTL
\bLS
\bS p
\bpo
\bol
\bli
\bic
\bcy
\by s
\bsu
\bup
\bpp
\bpo
\bor
\brt
\bt
1463 This section describes an obsolete per-site TLS policy mechanism. Unlike the
1464 Postfix 2.3 policy table mechanism, this uses as a policy lookup key a
1465 potentially untrusted server hostname, and lacks control over what names can
1466 appear in server certificates. Because of this, the obsolete mechanism is
1467 typically vulnerable to false DNS hostname information in MX or CNAME records.
1468 These attacks can be eliminated only with great difficulty. The new policy
1469 table makes secure-channel configurations easier and provides more control over
1470 the cipher and protocol selection for sessions with mandatory encryption.
1472 Avoid policy lookups with the bare hostname. Instead, use the full destination
1473 nexthop (enclosed in [] with a possible ":port" suffix) as the per-site table
1474 lookup key (a recipient domain or MX-enabled transport nexthop with no port
1475 suffix may look like a bare hostname, but is still a suitable destination).
1476 With Postfix 2.3 and later, use of the obsolete approach documented here is
1477 strongly discouraged: use the new policy table instead.
1479 Starting with Postfix 2.3, the underlying TLS enforcement levels are common to
1480 the obsolete per-site table and the new policy table. The main.cf
1481 smtp_tls_mandatory_ciphers and smtp_tls_mandatory_protocols parameters control
1482 the TLS ciphers and protocols for mandatory encryption regardless of which
1483 table is used. The smtp_tls_verify_cert_match parameter determines the match
1484 strategy for the obsolete "MUST" keyword in the same way as for the "verify"
1485 level in the new policy.
1487 With Postfix < 2.3, the obsolete smtp_tls_cipherlist parameter is also applied
1488 for opportunistic TLS sessions, and should be used with care, or not at all.
1489 Setting cipherlist restrictions that are incompatible with a remote SMTP server
1490 render that server unreachable, TLS handshakes are always attempted and always
1493 When smtp_tls_policy_maps is empty (default) and smtp_tls_per_site is not
1494 empty, the per-site table is searched for a policy that matches the following
1497 remote SMTP server hostname
1498 This is simply the DNS name of the server that the Postfix SMTP client
1499 connects to; this name may be obtained from other DNS lookups, such as
1500 MX lookups or CNAME lookups. Use of the hostname lookup key is
1501 discouraged; always use the next-hop destination instead.
1502 next-hop destination
1503 This is normally the domain portion of the recipient address, but it
1504 may be overridden by information from the transport(5) table, from the
1505 relayhost parameter setting, or from the relay_transport setting. When
1506 it is not the recipient domain, the next-hop destination can have the
1507 Postfix-specific form "[name]", "[name]:port", "name" or "name:port".
1508 This is the recommended lookup key for per-site policy lookups (and
1509 incidentally for SASL password lookups).
1511 When both the hostname lookup and the next-hop lookup succeed, the host policy
1512 does not automatically override the next-hop policy. Instead, precedence is
1513 given to either the more specific or the more secure per-site policy as
1516 The smtp_tls_per_site table uses a simple "name whitespace value" format.
1517 Specify host names or next-hop destinations on the left-hand side; no wildcards
1518 are allowed. On the right hand side specify one of the following keywords:
1521 No TLS. This overrides a less specific "MAY" lookup result from the
1522 alternate host or next-hop lookup key, and overrides the global
1523 smtp_use_tls, smtp_enforce_tls, and smtp_tls_enforce_peername settings.
1525 Opportunistic TLS. This has less precedence than a more specific result
1526 (including "NONE") from the alternate host or next-hop lookup key, and
1527 has less precedence than the more specific global "smtp_enforce_tls =
1528 yes" or "smtp_tls_enforce_peername = yes".
1530 Mandatory TLS encryption. This overrides a less secure "NONE" or a less
1531 specific "MAY" lookup result from the alternate host or next-hop lookup
1532 key, and overrides the global smtp_use_tls, smtp_enforce_tls and
1533 smtp_tls_enforce_peername settings.
1535 Mandatory server certificate verification. This overrides a less secure
1536 "NONE" and "MUST_NOPEERMATCH" or a less specific "MAY" lookup result
1537 from the alternate host or next-hop lookup key, and overrides the
1538 global smtp_use_tls, smtp_enforce_tls and smtp_tls_enforce_peername
1541 The precedences between global (main.cf) and per-site TLS policies can be
1542 summarized as follows:
1544 * When neither the remote SMTP server hostname nor the next-hop destination
1545 are found in the smtp_tls_per_site table, the policy is based on
1546 smtp_use_tls, smtp_enforce_tls and smtp_tls_enforce_peername. Note:
1547 "smtp_enforce_tls = yes" and "smtp_tls_enforce_peername = yes" imply
1548 "smtp_use_tls = yes".
1550 * When both hostname and next-hop destination lookups produce a result, the
1551 more specific per-site policy (NONE, MUST, etc) overrides the less specific
1552 one (MAY), and the more secure per-site policy (MUST, etc) overrides the
1553 less secure one (NONE).
1555 * After the per-site policy lookups are combined, the result generally
1556 overrides the global policy. The exception is the less specific "MAY" per-
1557 site policy, which is overruled by the more specific global
1558 "smtp_enforce_tls = yes" with server certificate verification as specified
1559 with the smtp_tls_enforce_peername parameter.
1561 C
\bCl
\blo
\bos
\bsi
\bin
\bng
\bg a
\ba D
\bDN
\bNS
\bS l
\blo
\boo
\bop
\bph
\bho
\bol
\ble
\be w
\bwi
\bit
\bth
\bh o
\bob
\bbs
\bso
\bol
\ble
\bet
\bte
\be p
\bpe
\ber
\br-
\b-s
\bsi
\bit
\bte
\be T
\bTL
\bLS
\bS p
\bpo
\bol
\bli
\bic
\bci
\bie
\bes
\bs
1563 For a general discussion of TLS security for SMTP see TLS limitations above.
1564 What follows applies only to Postfix 2.2.9 and subsequent Postfix 2.2 patch
1565 levels. Do not use this approach with Postfix 2.3 and later; instead see the
1566 instructions under secure server certificate verification.
1568 As long as no secure DNS lookup mechanism is available, false hostnames in MX
1569 or CNAME responses can change Postfix's notion of the server hostname that is
1570 used for TLS policy lookup and server certificate verification. Even with a
1571 perfect match between the server hostname and the server certificate, there is
1572 no guarantee that Postfix is connected to the right server. To avoid this
1573 loophole, take all of the following steps:
1575 1. Use a dedicated message delivery transport (for example, "securetls") as
1578 2. Eliminate MX lookups. Specify local transport(5) table entries for
1579 sensitive domains with explicit securetls:[mailhost] or securetls:
1580 [mailhost]:port destinations (you can assure security of this table unlike
1581 DNS). This prevents false hostname information in DNS MX records from
1582 changing Postfix's notion of the server hostname that is used for TLS
1583 policy lookup and server certificate verification. The "securetls"
1584 transport is configured to enforce TLS with peername verification, and to
1585 disable the SMTP connection cache which could interfere with enforcement of
1586 smtp_tls_per_site policies.
1588 3. Disallow CNAME hostname overrides. In main.cf, specify
1589 "smtp_cname_overrides_servername = no". This prevents false hostname
1590 information in DNS CNAME records from changing the server hostname that
1591 Postfix uses for TLS policy lookup and server certificate verification.
1592 This feature requires Postfix 2.2.9 or later. The default value is "no"
1593 starting with Postfix 2.3.
1597 We give the non-default "securetls" transport an explicit master.cf process
1598 limit, so that we don't raise its process limit when raising
1599 $default_process_limit. The total process limit for *all* transports should
1600 stay somewhat under 1024 (the typical select() file descriptor limit);
1601 otherwise transports may be throttled under steady high load, compounding
1602 congestion. It is not uncommon at high volume sites to set the default process
1603 limit to 500 or more.
1605 We also default the "securetls" transport TLS security level to MUST, obviating
1606 the need for per-site table entries for secure-channel destinations.
1608 /etc/postfix/main.cf:
1609 transport_maps = hash:/etc/postfix/transport
1611 /etc/postfix/transport:
1612 example.com securetls:[tls.example.com]
1614 /etc/postfix/master.cf:
1615 securetls unix - - n - 100 smtp
1616 -o smtp_enforce_tls=yes
1617 -o smtp_tls_enforce_peername=yes
1619 D
\bDi
\bis
\bsc
\bco
\bov
\bve
\ber
\bri
\bin
\bng
\bg s
\bse
\ber
\brv
\bve
\ber
\brs
\bs t
\bth
\bha
\bat
\bt s
\bsu
\bup
\bpp
\bpo
\bor
\brt
\bt T
\bTL
\bLS
\bS
1621 As we decide on a "per site" basis whether or not to use TLS, it would be good
1622 to have a list of sites that offered "STARTTLS". We can collect it ourselves
1625 If the smtp_tls_note_starttls_offer feature is enabled and a server offers
1626 STARTTLS while TLS is not already enabled for that server, the Postfix SMTP
1627 client logs a line as follows:
1629 postfix/smtp[pid]: Host offered STARTTLS: [hostname.example.com]
1633 /etc/postfix/main.cf:
1634 smtp_tls_note_starttls_offer = yes
1636 S
\bSe
\ber
\brv
\bve
\ber
\br c
\bce
\ber
\brt
\bti
\bif
\bfi
\bic
\bca
\bat
\bte
\be v
\bve
\ber
\bri
\bif
\bfi
\bic
\bca
\bat
\bti
\bio
\bon
\bn d
\bde
\bep
\bpt
\bth
\bh
1638 The server certificate verification depth is specified with the main.cf
1639 smtp_tls_scert_verifydepth parameter. The default verification depth is 9 (the
1640 OpenSSL default), for compatibility with Postfix versions before 2.5 where
1641 smtp_tls_scert_verifydepth was ignored. When you configure trust in a root CA,
1642 it is not necessary to explicitly trust intermediary CAs signed by the root CA,
1643 unless $smtp_tls_scert_verifydepth is less than the number of CAs in the
1644 certificate chain for the servers of interest. With a verify depth of 1 you can
1645 only verify certificates directly signed by a trusted CA, and all trusted
1646 intermediary CAs need to be configured explicitly. With a verify depth of 2 you
1647 can verify servers signed by a root CA or a direct intermediary CA (so long as
1648 the server is correctly configured to supply its intermediate CA certificate).
1652 /etc/postfix/main.cf:
1653 smtp_tls_scert_verifydepth = 2
1655 C
\bCl
\bli
\bie
\ben
\bnt
\bt-
\b-s
\bsi
\bid
\bde
\be c
\bci
\bip
\bph
\bhe
\ber
\br c
\bco
\bon
\bnt
\btr
\bro
\bol
\bls
\bs
1657 The Postfix SMTP client supports 5 distinct cipher security levels as specified
1658 by the smtp_tls_mandatory_ciphers configuration parameter. This setting
1659 controls the minimum acceptable SMTP client TLS cipher grade for use with
1660 mandatory TLS encryption. The default value "medium" is suitable for most
1661 destinations with which you may want to enforce TLS, and is beyond the reach of
1662 today's crypt-analytic methods. See smtp_tls_policy_maps for information on how
1663 to configure ciphers on a per-destination basis.
1665 By default anonymous ciphers are allowed, and automatically disabled when
1666 remote SMTP server certificates are verified. If you want to disable anonymous
1667 ciphers even at the "encrypt" security level, set
1668 "smtp_tls_mandatory_exclude_ciphers = aNULL"; and to disable anonymous ciphers
1669 even with opportunistic TLS, set "smtp_tls_exclude_ciphers = aNULL". There is
1670 generally no need to take these measures. Anonymous ciphers save bandwidth and
1671 TLS session cache space, if certificates are ignored, there is little point in
1674 The "smtp_tls_ciphers" configuration parameter (Postfix >= 2.6) provides
1675 control over the minimum cipher grade for opportunistic TLS. With Postfix <
1676 2.6, the minimum opportunistic TLS cipher grade is always "export".
1678 With mandatory TLS encryption, the Postfix SMTP client will by default only use
1679 SSLv3 or TLSv1. SSLv2 is only used when TLS encryption is optional. The
1680 mandatory TLS protocol list is specified via the smtp_tls_mandatory_protocols
1681 configuration parameter. The corresponding smtp_tls_protocols parameter
1682 (Postfix >= 2.6) controls the SSL/TLS protocols used with opportunistic TLS.
1686 /etc/postfix/main.cf:
1687 smtp_tls_mandatory_ciphers = medium
1688 smtp_tls_mandatory_exclude_ciphers = RC4, MD5
1689 smtp_tls_exclude_ciphers = aNULL
1690 smtp_tls_mandatory_protocols = SSLv3, TLSv1
1691 # Also available with Postfix >= 2.5:
1692 smtp_tls_mandatory_protocols = !SSLv2
1693 # Also available with Postfix >= 2.6:
1694 smtp_tls_ciphers = export
1695 smtp_tls_protocols = !SSLv2
1697 C
\bCl
\bli
\bie
\ben
\bnt
\bt-
\b-s
\bsi
\bid
\bde
\be S
\bSM
\bMT
\bTP
\bPS
\bS s
\bsu
\bup
\bpp
\bpo
\bor
\brt
\bt
1699 Although the Postfix SMTP client by itself doesn't support TLS wrapper mode, it
1700 is relatively easy to forward a connection through the stunnel program if
1701 Postfix needs to deliver mail to some legacy system that doesn't support
1702 STARTTLS. Use one of the following two examples, to send only some remote mail,
1703 or to send all remote mail, to an SMTPS server.
1705 S
\bSe
\ben
\bnd
\bdi
\bin
\bng
\bg a
\bal
\bll
\bl r
\bre
\bem
\bmo
\bot
\bte
\be m
\bma
\bai
\bil
\bl t
\bto
\bo a
\ban
\bn S
\bSM
\bMT
\bTP
\bPS
\bS s
\bse
\ber
\brv
\bve
\ber
\br
1707 The first example uses SMTPS to send all remote mail to a provider's mail
1708 server called "mail.example.com".
1710 A minimal stunnel.conf file is sufficient to set up a tunnel from local port
1711 11125 to the remote destination "mail.example.com" and port "smtps". Postfix
1712 will later use this tunnel to connect to the remote server.
1714 /path/to/stunnel.conf:
1718 connect = mail.example.com:smtps
1720 To test this tunnel, use:
1722 $ telnet localhost 11125
1724 This should produce the greeting from the remote SMTP server at
1727 On the Postfix side, the relayhost feature sends all remote mail through the
1728 local stunnel listener on port 11125:
1730 /etc/postfix/main.cf:
1731 relayhost = [127.0.0.1]:11125
1733 Use "postfix reload" to make the change effective.
1735 S
\bSe
\ben
\bnd
\bdi
\bin
\bng
\bg o
\bon
\bnl
\bly
\by m
\bma
\bai
\bil
\bl f
\bfo
\bor
\br a
\ba s
\bsp
\bpe
\bec
\bci
\bif
\bfi
\bic
\bc d
\bde
\bes
\bst
\bti
\bin
\bna
\bat
\bti
\bio
\bon
\bn v
\bvi
\bia
\ba S
\bSM
\bMT
\bTP
\bPS
\bS
1737 The second example will use SMTPS to send only mail for "example.com" via
1738 SMTPS. It uses the same stunnel configuration file as the first example, so it
1739 won't be repeated here.
1741 This time, the Postfix side uses a transport map to direct only mail for
1742 "example.com" through the tunnel:
1744 /etc/postfix/main.cf:
1745 transport_maps = hash:/etc/postfix/transport
1747 /etc/postfix/transport:
1748 example.com relay:[127.0.0.1]:11125
1750 Use "postmap hash:/etc/postfix/transport" and "postfix reload" to make the
1753 M
\bMi
\bis
\bsc
\bce
\bel
\bll
\bla
\ban
\bne
\beo
\bou
\bus
\bs c
\bcl
\bli
\bie
\ben
\bnt
\bt c
\bco
\bon
\bnt
\btr
\bro
\bol
\bls
\bs
1755 The smtp_starttls_timeout parameter limits the time of Postfix SMTP client
1756 write and read operations during TLS startup and shutdown handshake procedures.
1757 In case of problems the Postfix SMTP client tries the next network address on
1758 the mail exchanger list, and defers delivery if no alternative server is
1763 /etc/postfix/main.cf:
1764 smtp_starttls_timeout = 300s
1766 T
\bTL
\bLS
\bS m
\bma
\ban
\bna
\bag
\bge
\ber
\br s
\bsp
\bpe
\bec
\bci
\bif
\bfi
\bic
\bc s
\bse
\bet
\btt
\bti
\bin
\bng
\bgs
\bs
1768 The security of cryptographic software such as TLS depends critically on the
1769 ability to generate unpredictable numbers for keys and other information. To
1770 this end, the tlsmgr(8) process maintains a Pseudo Random Number Generator
1771 (PRNG) pool. This is queried by the smtp(8) and smtpd(8) processes when they
1772 initialize. By default, these daemons request 32 bytes, the equivalent to 256
1773 bits. This is more than sufficient to generate a 128bit (or 168bit) session
1778 /etc/postfix/main.cf:
1779 tls_daemon_random_bytes = 32
1781 In order to feed its in-memory PRNG pool, the tlsmgr(8) reads entropy from an
1782 external source, both at startup and during run-time. Specify a good entropy
1783 source, like EGD or /dev/urandom; be sure to only use non-blocking sources (on
1784 OpenBSD, use /dev/arandom when tlsmgr(8) complains about /dev/urandom timeout
1785 errors). If the entropy source is not a regular file, you must prepend the
1786 source type to the source name: "dev:" for a device special file, or "egd:" for
1787 a source with EGD compatible socket interface.
1789 Examples (specify only one in main.cf):
1791 /etc/postfix/main.cf:
1792 tls_random_source = dev:/dev/urandom
1793 tls_random_source = egd:/var/run/egd-pool
1795 By default, tlsmgr(8) reads 32 bytes from the external entropy source at each
1796 seeding event. This amount (256bits) is more than sufficient for generating a
1797 128bit symmetric key. With EGD and device entropy sources, the tlsmgr(8) limits
1798 the amount of data read at each step to 255 bytes. If you specify a regular
1799 file as entropy source, a larger amount of data can be read.
1803 /etc/postfix/main.cf:
1804 tls_random_bytes = 32
1806 In order to update its in-memory PRNG pool, the tlsmgr(8) queries the external
1807 entropy source again after a pseudo-random amount of time. The time is
1808 calculated using the PRNG, and is between 0 and the maximal time specified with
1809 tls_random_reseed_period. The default maximal time interval is 1 hour.
1813 /etc/postfix/main.cf:
1814 tls_random_reseed_period = 3600s
1816 The tlsmgr(8) process saves the PRNG state to a persistent exchange file at
1817 regular times and when the process terminates, so that it can recover the PRNG
1818 state the next time it starts up. This file is created when it does not exist.
1822 /etc/postfix/main.cf:
1823 tls_random_exchange_name = /var/db/postfix/prng_exch
1824 tls_random_prng_update_period = 3600s
1826 As of version 2.5, Postfix no longer uses root privileges when opening this
1827 file. The file should now be stored under the Postfix-owned data_directory. As
1828 a migration aid, an attempt to open the file under a non-Postfix directory is
1829 redirected to the Postfix-owned data_directory, and a warning is logged. If you
1830 wish to continue using a pre-existing PRNG state file, move it to the
1831 data_directory and change the ownership to the account specified with the
1832 mail_owner parameter.
1834 With earlier Postfix versions the default file location is under the Postfix
1835 configuration directory, which is not the proper place for information that is
1836 modified by Postfix.
1838 G
\bGe
\bet
\btt
\bti
\bin
\bng
\bg s
\bst
\bta
\bar
\brt
\bte
\bed
\bd,
\b, q
\bqu
\bui
\bic
\bck
\bk a
\ban
\bnd
\bd d
\bdi
\bir
\brt
\bty
\by
1840 The following steps will get you started quickly. Because you sign your own
1841 Postfix public key certificate, you get TLS encryption but no TLS
1842 authentication. This is sufficient for testing, and for exchanging email with
1843 sites that you have no trust relationship with. For real authentication, your
1844 Postfix public key certificate needs to be signed by a recognized Certificate
1845 Authority, and Postfix needs to be configured with a list of public key
1846 certificates of Certificate Authorities, so that Postfix can verify the public
1847 key certificates of remote hosts.
1849 In the examples below, user input is shown in b
\bbo
\bol
\bld
\bd font, and a "#" prompt
1850 indicates a super-user shell.
1852 * Become your own Certificate Authority, so that you can sign your own public
1853 keys. This example uses the CA.pl script that ships with OpenSSL. By
1854 default, OpenSSL installs this as /usr/local/ssl/misc/CA.pl, but your
1855 mileage may vary. The script creates a private key in ./demoCA/private/
1856 cakey.pem and a public key in ./demoCA/cacert.pem.
1858 % /
\b/u
\bus
\bsr
\br/
\b/l
\blo
\boc
\bca
\bal
\bl/
\b/s
\bss
\bsl
\bl/
\b/m
\bmi
\bis
\bsc
\bc/
\b/C
\bCA
\bA.
\b.p
\bpl
\bl -
\b-n
\bne
\bew
\bwc
\bca
\ba
1859 CA certificate filename (or enter to create)
1861 Making CA certificate ...
1862 Using configuration from /etc/ssl/openssl.cnf
1863 Generating a 1024 bit RSA private key
1864 ....................++++++
1866 writing new private key to './demoCA/private/cakey.pem'
1867 Enter PEM pass phrase:w
\bwh
\bha
\bat
\bte
\bev
\bve
\ber
\br
1869 * Create an unpassworded private key for host foo.porcupine.org and create an
1870 unsigned public key certificate.
1872 % o
\bop
\bpe
\ben
\bns
\bss
\bsl
\bl r
\bre
\beq
\bq -
\b-n
\bne
\bew
\bw -
\b-n
\bno
\bod
\bde
\bes
\bs -
\b-k
\bke
\bey
\byo
\bou
\but
\bt f
\bfo
\boo
\bo-
\b-k
\bke
\bey
\by.
\b.p
\bpe
\bem
\bm -
\b-o
\bou
\but
\bt f
\bfo
\boo
\bo-
\b-r
\bre
\beq
\bq.
\b.p
\bpe
\bem
\bm -
\b-d
\bda
\bay
\bys
\bs
1874 Using configuration from /etc/ssl/openssl.cnf
1875 Generating a 1024 bit RSA private key
1876 ........................................++++++
1878 writing new private key to 'foo-key.pem'
1880 You are about to be asked to enter information that will be
1882 into your certificate request.
1883 What you are about to enter is what is called a Distinguished Name or a
1885 There are quite a few fields but you can leave some blank
1886 For some fields there will be a default value,
1887 If you enter '.', the field will be left blank.
1889 Country Name (2 letter code) [AU]:U
\bUS
\bS
1890 State or Province Name (full name) [Some-State]:N
\bNe
\bew
\bw Y
\bYo
\bor
\brk
\bk
1891 Locality Name (eg, city) []:W
\bWe
\bes
\bst
\btc
\bch
\bhe
\bes
\bst
\bte
\ber
\br
1892 Organization Name (eg, company) [Internet Widgits Pty Ltd]:P
\bPo
\bor
\brc
\bcu
\bup
\bpi
\bin
\bne
\be
1893 Organizational Unit Name (eg, section) []:
1894 Common Name (eg, YOUR name) []:f
\bfo
\boo
\bo.
\b.p
\bpo
\bor
\brc
\bcu
\bup
\bpi
\bin
\bne
\be.
\b.o
\bor
\brg
\bg
1895 Email Address []:w
\bwi
\bie
\bet
\bts
\bse
\be@
\b@p
\bpo
\bor
\brc
\bcu
\bup
\bpi
\bin
\bne
\be.
\b.o
\bor
\brg
\bg
1897 Please enter the following 'extra' attributes
1898 to be sent with your certificate request
1899 A challenge password []:w
\bwh
\bha
\bat
\bte
\bev
\bve
\ber
\br
1900 An optional company name []:
1902 * Sign the public key certificate for host foo.porcupine.org with the
1903 Certification Authority private key that we created a few steps ago.
1905 % o
\bop
\bpe
\ben
\bns
\bss
\bsl
\bl c
\bca
\ba -
\b-o
\bou
\but
\bt f
\bfo
\boo
\bo-
\b-c
\bce
\ber
\brt
\bt.
\b.p
\bpe
\bem
\bm -
\b-i
\bin
\bnf
\bfi
\bil
\ble
\bes
\bs f
\bfo
\boo
\bo-
\b-r
\bre
\beq
\bq.
\b.p
\bpe
\bem
\bm
1906 Using configuration from /etc/ssl/openssl.cnf
1907 Enter PEM pass phrase:w
\bwh
\bha
\bat
\bte
\bev
\bve
\ber
\br
1908 Check that the request matches the signature
1910 The Subjects Distinguished Name is as follows
1911 countryName :PRINTABLE:'US'
1912 stateOrProvinceName :PRINTABLE:'New York'
1913 localityName :PRINTABLE:'Westchester'
1914 organizationName :PRINTABLE:'Porcupine'
1915 commonName :PRINTABLE:'foo.porcupine.org'
1916 emailAddress :IA5STRING:'wietse@porcupine.org'
1917 Certificate is to be certified until Nov 21 19:40:56 2005 GMT (365
1919 Sign the certificate? [y/n]:y
\by
1921 1 out of 1 certificate requests certified, commit? [y/n]y
\by
1922 Write out database with 1 new entries
1925 * Install the host private key, the host public key certificate, and the
1926 Certification Authority certificate files. This requires super-user
1929 # c
\bcp
\bp d
\bde
\bem
\bmo
\boC
\bCA
\bA/
\b/c
\bca
\bac
\bce
\ber
\brt
\bt.
\b.p
\bpe
\bem
\bm f
\bfo
\boo
\bo-
\b-k
\bke
\bey
\by.
\b.p
\bpe
\bem
\bm f
\bfo
\boo
\bo-
\b-c
\bce
\ber
\brt
\bt.
\b.p
\bpe
\bem
\bm /
\b/e
\bet
\btc
\bc/
\b/p
\bpo
\bos
\bst
\btf
\bfi
\bix
\bx
1930 # c
\bch
\bhm
\bmo
\bod
\bd 6
\b64
\b44
\b4 /
\b/e
\bet
\btc
\bc/
\b/p
\bpo
\bos
\bst
\btf
\bfi
\bix
\bx/
\b/f
\bfo
\boo
\bo-
\b-c
\bce
\ber
\brt
\bt.
\b.p
\bpe
\bem
\bm /
\b/e
\bet
\btc
\bc/
\b/p
\bpo
\bos
\bst
\btf
\bfi
\bix
\bx/
\b/c
\bca
\bac
\bce
\ber
\brt
\bt.
\b.p
\bpe
\bem
\bm
1931 # c
\bch
\bhm
\bmo
\bod
\bd 4
\b40
\b00
\b0 /
\b/e
\bet
\btc
\bc/
\b/p
\bpo
\bos
\bst
\btf
\bfi
\bix
\bx/
\b/f
\bfo
\boo
\bo-
\b-k
\bke
\bey
\by.
\b.p
\bpe
\bem
\bm
1933 * Configure Postfix, by adding the following to /etc/postfix/main.cf. It is
1934 generally best to not configure client certificates, unless there are
1935 servers which authenticate your mail submission via client certificates.
1936 Often servers that perform TLS client authentication will issue the
1937 required certificates signed by their own CA. If you configure the client
1938 certificate and key incorrectly, you will be unable to send mail to sites
1939 that request client certificate, but don't require them from all clients.
1941 /etc/postfix/main.cf:
1942 smtp_tls_CAfile = /etc/postfix/cacert.pem
1943 smtp_tls_session_cache_database =
1944 btree:/var/db/postfix/smtp_tls_session_cache
1945 smtp_tls_security_level = may
1946 smtpd_tls_CAfile = /etc/postfix/cacert.pem
1947 smtpd_tls_cert_file = /etc/postfix/foo-cert.pem
1948 smtpd_tls_key_file = /etc/postfix/foo-key.pem
1949 smtpd_tls_received_header = yes
1950 smtpd_tls_session_cache_database =
1951 btree:/var/db/postfix/smtpd_tls_session_cache
1952 tls_random_source = dev:/dev/urandom
1953 # Postfix 2.3 and later
1954 smtpd_tls_security_level = may
1955 # Obsolete, but still supported
1958 R
\bRe
\bep
\bpo
\bor
\brt
\bti
\bin
\bng
\bg p
\bpr
\bro
\bob
\bbl
\ble
\bem
\bms
\bs
1960 Problems are preferably reported via <postfix-users@postfix.org>. See http://
1961 www.postfix.org/lists.html for subscription information. When reporting a
1962 problem, please be thorough in the report. Patches, when possible, are greatly
1965 C
\bCr
\bre
\bed
\bdi
\bit
\bts
\bs
1967 * TLS support for Postfix was originally developed by Lutz Jänicke at Cottbus
1968 Technical University.
1969 * Wietse Venema adopted the code, did some restructuring, and compiled this
1970 part of the documentation from Lutz's documents.
1971 * Victor Duchovni was instrumental with the re-implementation of the
1972 smtp_tls_per_site code in terms of enforcement levels, which simplified the
1973 implementation greatly.
1974 * Victor Duchovni implemented the fingerprint security level, added more
1975 sanity checks, and separated TLS connection management from security policy
1976 enforcement. The latter change simplified the code that verifies
1977 certificate signatures, certificate names, and certificate fingerprints.