1 P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx l
\ble
\beg
\bga
\bac
\bcy
\by T
\bTL
\bLS
\bS S
\bSu
\bup
\bpp
\bpo
\bor
\brt
\bt
3 -------------------------------------------------------------------------------
7 This document describes an old TLS user interface that is based on a third-
8 party TLS patch by Lutz Jänicke. As of Postfix version 2.3, the old user
9 interface still exists to allow migration from earlier Postfix releases, but
10 its functionality is frozen.
12 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
14 Transport Layer Security (TLS, formerly called SSL) provides certificate-based
15 authentication and encrypted sessions. An encrypted session protects the
16 information that is transmitted with SMTP mail or with SASL authentication.
18 Postfix version 2.2 introduces support for TLS as described in RFC 3207. TLS
19 Support for older Postfix versions was available as an add-on patch. The
20 section "Compatibility with Postfix < 2.2 TLS support" below discusses the
21 differences between these implementations.
23 Topics covered in this document:
25 * How Postfix TLS support works
26 * Building Postfix with TLS support
27 * SMTP Server specific settings
28 * SMTP Client specific settings
29 * TLS manager specific settings
31 * Compatibility with Postfix < 2.2 TLS support
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 <-session-> <-session->
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 To build Postfix with TLS support, first we need to generate the make(1) files
67 with the necessary definitions. This is done by invoking the command "make
68 makefiles" in the Postfix top-level directory and with arguments as shown next.
70 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
71 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
72 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
73 a
\bap
\bpp
\bpr
\bro
\bop
\bpr
\bri
\bia
\bat
\bte
\be.
\b.
75 * If the OpenSSL include files (such as ssl.h) are in directory /usr/include/
76 openssl, and the OpenSSL libraries (such as libssl.so and libcrypto.so) are
77 in directory /usr/lib:
79 % m
\bma
\bak
\bke
\be t
\bti
\bid
\bdy
\by # if you have left-over files from a previous build
80 % 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"
82 * If the OpenSSL include files (such as ssl.h) are in directory /usr/local/
83 include/openssl, and the OpenSSL libraries (such as libssl.so and
84 libcrypto.so) are in directory /usr/local/lib:
86 % m
\bma
\bak
\bke
\be t
\bti
\bid
\bdy
\by # if you have left-over files from a previous build
87 % 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\
88 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"
90 On Solaris, specify the -R option as shown below:
92 % m
\bma
\bak
\bke
\be t
\bti
\bid
\bdy
\by # if you have left-over files from a previous build
93 % 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\
94 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"
96 If you need to apply other customizations (such as Berkeley DB databases,
97 MySQL, PosgreSQL, LDAP or SASL), see the respective Postfix README documents,
98 and combine their "make makefiles" instructions with the instructions above:
100 % m
\bma
\bak
\bke
\be t
\bti
\bid
\bdy
\by # if you have left-over files from a previous build
101 % 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\
102 (
\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\
103 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\
104 (
\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\
105 (
\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"
107 To complete the build process, see the Postfix INSTALL instructions. Postfix
108 has TLS support turned off by default, so you can start using Postfix as soon
111 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
113 Topics covered in this section:
115 * Server-side certificate and private key configuration
116 * Server-side TLS activity logging
117 * Enabling TLS in the Postfix SMTP server
118 * Client certificate verification
119 * Supporting AUTH over TLS only
120 * Server-side TLS session cache
121 * Server access control
122 * Server-side cipher controls
123 * Miscellaneous server controls
125 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
127 In order to use TLS, the Postfix SMTP server needs a certificate and a private
128 key. Both must be in "pem" format. The private key must not be encrypted,
129 meaning: the key must be accessible without password. Both certificate and
130 private key may be in the same file.
132 Both RSA and DSA certificates are supported. Typically you will only have RSA
133 certificates issued by a commercial CA. In addition, the tools supplied with
134 OpenSSL will by default issue RSA certificates. You can have both at the same
135 time, in which case the cipher used determines which certificate is presented.
136 For Netscape and OpenSSL clients without special cipher choices, the RSA
137 certificate is preferred.
139 In order for remote SMTP clients to check the Postfix SMTP server certificates,
140 the CA certificate (in case of a certificate chain, all CA certificates) must
141 be available. You should add these certificates to the server certificate, the
142 server certificate first, then the issuing CA(s).
144 Example: the certificate for "server.dom.ain" was issued by "intermediate CA"
145 which itself has a certificate issued by "root CA". Create the server.pem file
148 % 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
150 A Postfix SMTP server certificate supplied here must be usable as SSL server
151 certificate and hence pass the "openssl verify -purpose sslserver ..." test.
153 A client that trusts the root CA has a local copy of the root CA certificate,
154 so it is not necessary to include the root CA certificate here. Leaving it out
155 of the "server.pem" file reduces the overhead of the TLS exchange.
157 If you want the Postfix SMTP server to accept remote SMTP client certificates
158 issued by these CAs, append the root certificate to $smtpd_tls_CAfile or
159 install it in the $smtpd_tls_CApath directory. When you configure trust in a
160 root CA, it is not necessary to explicitly trust intermediary CAs signed by the
161 root CA, unless $smtpd_tls_ccert_verifydepth is less than the number of CAs in
162 the certificate chain for the clients of interest. With a verify depth of 1 you
163 can only verify certificates directly signed by a trusted CA, and all trusted
164 intermediary CAs need to be configured explicitly. With a verify depth of 2 you
165 can verify clients signed by a root CA or a direct intermediary CA (so long as
166 the client is correctly configured to supply its intermediate CA certificate).
168 RSA key and certificate examples:
170 /etc/postfix/main.cf:
171 smtpd_tls_cert_file = /etc/postfix/server.pem
172 smtpd_tls_key_file = $smtpd_tls_cert_file
174 Their DSA counterparts:
176 /etc/postfix/main.cf:
177 smtpd_tls_dcert_file = /etc/postfix/server-dsa.pem
178 smtpd_tls_dkey_file = $smtpd_tls_dcert_file
180 To verify a remote SMTP client certificate, the Postfix SMTP server needs to
181 trust the certificates of the issuing certification authorities. These
182 certificates in "pem" format can be stored in a single $smtpd_tls_CAfile or in
183 multiple files, one CA per file in the $smtpd_tls_CApath directory. If you use
184 a directory, don't forget to create the necessary "hash" links with:
186 # $
\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
188 The $smtpd_tls_CAfile contains the CA certificates of one or more trusted CAs.
189 The file is opened (with root privileges) before Postfix enters the optional
190 chroot jail and so need not be accessible from inside the chroot jail.
192 Additional trusted CAs can be specified via the $smtpd_tls_CApath directory, in
193 which case the certificates are read (with $mail_owner privileges) from the
194 files in the directory when the information is needed. Thus, the
195 $smtpd_tls_CApath directory needs to be accessible inside the optional chroot
198 When you configure Postfix to request client certificates (by setting
199 $smtpd_tls_ask_ccert = yes), any certificates in $smtpd_tls_CAfile are sent to
200 the client, in order to allow it to choose an identity signed by a CA you
201 trust. If no $smtpd_tls_CAfile is specified, no preferred CA list is sent, and
202 the client is free to choose an identity signed by any CA. Many clients use a
203 fixed identity regardless of the preferred CA list and you may be able to
204 reduce TLS negotiation overhead by installing client CA certificates mostly or
205 only in $smtpd_tls_CApath. In the latter case you need not specify a
208 Note, that unless client certificates are used to allow greater access to TLS
209 authenticated clients, it is best to not ask for client certificates at all, as
210 in addition to increased overhead some clients (notably in some cases qmail)
211 are unable to complete the TLS handshake when client certificates are
216 /etc/postfix/main.cf:
217 smtpd_tls_CAfile = /etc/postfix/CAcert.pem
218 smtpd_tls_CApath = /etc/postfix/certs
220 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
222 To get additional information about Postfix SMTP server TLS activity you can
223 increase the loglevel from 0..4. Each logging level also includes the
224 information that is logged at a lower logging level.
226 0 Disable logging of TLS activity.
228 1 Log TLS handshake and certificate information.
230 2 Log levels during TLS negotiation.
232 3 Log hexadecimal and ASCII dump of TLS negotiation process
234 4 Log hexadecimal and ASCII dump of complete transmission after STARTTLS
236 Use loglevel 3 only in case of problems. Use of loglevel 4 is strongly
241 /etc/postfix/main.cf:
242 smtpd_tls_loglevel = 0
244 To include information about the protocol and cipher used as well as the client
245 and issuer CommonName into the "Received:" message header, set the
246 smtpd_tls_received_header variable to true. The default is no, as the
247 information is not necessarily authentic. Only information recorded at the
248 final destination is reliable, since the headers may be changed by intermediate
253 /etc/postfix/main.cf:
254 smtpd_tls_received_header = yes
256 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
258 By default, TLS is disabled in the Postfix SMTP server, so no difference to
259 plain Postfix is visible. Explicitly switch it on using "smtpd_use_tls = yes".
263 /etc/postfix/main.cf:
266 With this, Postfix SMTP server announces STARTTLS support to SMTP clients, but
267 does not require that clients use TLS encryption.
269 Note: when an unprivileged user invokes "sendmail -bs", STARTTLS is never
270 offered due to insufficient privileges to access the server private key. This
271 is intended behavior.
273 You can ENFORCE the use of TLS, so that the Postfix SMTP server announces
274 STARTTLS and accepts no mail without TLS encryption, by setting
275 "smtpd_enforce_tls = yes". According to RFC 2487 this MUST NOT be applied in
276 case of a publicly-referenced Postfix SMTP server. This option is off by
277 default and should only seldom be used.
281 /etc/postfix/main.cf:
282 smtpd_enforce_tls = yes
284 TLS is sometimes used in the non-standard "wrapper" mode where a server always
285 uses TLS, instead of announcing STARTTLS support and waiting for clients to
286 request TLS service. Some clients, namely Outlook [Express] prefer the
287 "wrapper" mode. This is true for OE (Win32 < 5.0 and Win32 >=5.0 when run on a
288 port<>25 and OE (5.01 Mac on all ports).
290 It is strictly discouraged to use this mode from main.cf. If you want to
291 support this service, enable a special port in master.cf and specify "-
292 o smtpd_tls_wrappermode = yes" as an smtpd(8) command line option. Port 465
293 (smtps) was once chosen for this feature.
297 /etc/postfix/master.cf:
298 smtps inet n - n - - smtpd
299 -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes
301 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
303 To receive a remote SMTP client certificate, the Postfix SMTP server must
304 explicitly ask for one (any contents of $smtpd_tls_CAfile are also sent to the
305 client as a hint for choosing a certificate from a suitable CA). Unfortunately,
306 Netscape clients will either complain if no matching client certificate is
307 available or will offer the user client a list of certificates to choose from.
308 Additionally some MTAs (notably some versions of qmail) are unable to complete
309 TLS negotiation when client certificates are requested, and abort the SMTP
310 session. So this option is "off" by default. You will however need the
311 certificate if you want to use certificate based relaying with, for example,
312 the permit_tls_clientcerts feature.
316 /etc/postfix/main.cf:
317 smtpd_tls_ask_ccert = no
319 You may also decide to REQUIRE a remote SMTP client certificate before allowing
320 TLS connections. This feature is included for completeness, and implies
321 "smtpd_tls_ask_ccert = yes".
323 Please be aware, that this will inhibit TLS connections without a proper client
324 certificate and that it makes sense only when non-TLS submission is disabled
325 (smtpd_enforce_tls = yes). Otherwise, clients could bypass the restriction by
326 simply not using STARTTLS at all.
328 When TLS is not enforced, the connection will be handled as if only
329 "smtpd_tls_ask_ccert = yes" is specified, and a warning is logged.
333 /etc/postfix/main.cf:
334 smtpd_tls_req_ccert = no
336 A client certificate verification depth of 1 is sufficient if the certificate
337 is directly issued by a CA listed in the CA file. The default value (5) should
338 also suffice for longer chains (root CA issues special CA which then issues the
339 actual certificate...)
343 /etc/postfix/main.cf:
344 smtpd_tls_ccert_verifydepth = 5
346 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
348 Sending AUTH data over an unencrypted channel poses a security risk. When TLS
349 layer encryption is required (smtpd_enforce_tls = yes), the Postfix SMTP server
350 will announce and accept AUTH only after the TLS layer has been activated with
351 STARTTLS. When TLS layer encryption is optional (smtpd_enforce_tls = no), it
352 may however still be useful to only offer AUTH when TLS is active. To maintain
353 compatibility with non-TLS clients, the default is to accept AUTH without
354 encryption. In order to change this behavior, set "smtpd_tls_auth_only = yes".
358 /etc/postfix/main.cf:
359 smtpd_tls_auth_only = no
361 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
363 The Postfix SMTP server and the remote SMTP client negotiate a session, which
364 takes some computer time and network bandwidth. By default, this session
365 information is cached only in the smtpd(8) process actually using this session
366 and is lost when the process terminates. To share the session information
367 between multiple smtpd(8) processes, a persistent session cache can be used.
368 You can specify any database type that can store objects of several kbytes and
369 that supports the sequence operator. DBM databases are not suitable because
370 they can only store small objects. The cache is maintained by the tlsmgr(8)
371 process, so there is no problem with concurrent access. Session caching is
372 highly recommended, because the cost of repeatedly negotiating TLS session keys
377 /etc/postfix/main.cf:
378 smtpd_tls_session_cache_database = btree:/etc/postfix/smtpd_scache
380 As of version 2.5, Postfix will no longer maintain this file in a directory
381 with non-Postfix ownership. As a migration aid, attempts to open such files are
382 redirected to the Postfix-owned $data_directory, and a warning is logged.
384 Cached Postfix SMTP server session information expires after a certain amount
385 of time. Postfix/TLS does not use the OpenSSL default of 300s, but a longer
386 time of 3600sec (=1 hour). RFC 2246 recommends a maximum of 24 hours.
390 /etc/postfix/main.cf:
391 smtpd_tls_session_cache_timeout = 3600s
393 S
\bSe
\ber
\brv
\bve
\ber
\br a
\bac
\bcc
\bce
\bes
\bss
\bs c
\bco
\bon
\bnt
\btr
\bro
\bol
\bl
395 Postfix TLS support introduces three additional features for Postfix SMTP
396 server access control:
398 permit_tls_clientcerts
399 Allow the remote SMTP client SMTP request if the client certificate
400 passes verification, and if its fingerprint is listed in the list of
401 client certificates (see relay_clientcerts discussion below).
403 permit_tls_all_clientcerts
404 Allow the remote client SMTP request if the client certificate passes
407 check_ccert_access type:table
408 If the client certificate passes verification, use its fingerprint as a
409 key for the specified access(5) table.
411 The permit_tls_all_clientcerts feature must be used with caution, because it
412 can result in too many access permissions. Use this feature only if a special
413 CA issues the client certificates, and only if this CA is listed as trusted CA.
414 If other CAs are trusted, any owner of a valid client certificate would be
415 authorized. The permit_tls_all_clientcerts feature can be practical for a
416 specially created email relay server.
418 It is however recommended to stay with the permit_tls_clientcerts feature and
419 list all certificates via $relay_clientcerts, as permit_tls_all_clientcerts
420 does not permit any control when a certificate must no longer be used (e.g. an
425 /etc/postfix/main.cf:
426 smtpd_recipient_restrictions =
428 permit_tls_clientcerts
429 reject_unauth_destination
432 The Postfix list manipulation routines give special treatment to whitespace and
433 some other characters, making the use of certificate names impractical. Instead
434 we use the certificate fingerprints as they are difficult to fake but easy to
435 use for lookup. Postfix lookup tables are in the form of (key, value) pairs.
436 Since we only need the key, the value can be chosen freely, e.g. the name of
441 /etc/postfix/main.cf:
442 relay_clientcerts = hash:/etc/postfix/relay_clientcerts
444 /etc/postfix/relay_clientcerts:
445 D7:04:2F:A7:0B:8C:A5:21:FA:31:77:E1:41:8A:EE:80 lutzpc.at.home
447 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
449 To influence the Postfix SMTP server cipher selection scheme, you can give
450 cipherlist string. A detailed description would go to far here; please refer to
451 the OpenSSL documentation. If you don't know what to do with it, simply don't
452 touch it and leave the (openssl-)compiled in default!
454 DO NOT USE " to enclose the string, specify just the string!!!
458 /etc/postfix/main.cf:
459 smtpd_tls_cipherlist = DEFAULT
461 If you want to take advantage of ciphers with EDH, DH parameters are needed.
462 Instead of using the built-in DH parameters for both 1024bit and 512bit, it is
463 better to generate "own" parameters, since otherwise it would "pay" for a
464 possible attacker to start a brute force attack against parameters that are
465 used by everybody. For this reason, the parameters chosen are already different
466 from those distributed with other TLS packages.
468 To generate your own set of DH parameters, use:
470 % 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 -
\b-r
\bra
\ban
\bnd
\bd /
\b/v
\bva
\bar
\br/
\b/r
\bru
\bun
\bn/
\b/e
\beg
\bgd
\bd-
\b-p
\bpo
\boo
\bol
\bl
472 % 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 -
\b-r
\bra
\ban
\bnd
\bd /
\b/v
\bva
\bar
\br/
\b/r
\bru
\bun
\bn/
\b/e
\beg
\bgd
\bd-
\b-p
\bpo
\boo
\bol
\bl 5
\b51
\b12
\b2
476 /etc/postfix/main.cf:
477 smtpd_tls_dh1024_param_file = /etc/postfix/dh_1024.pem
478 smtpd_tls_dh512_param_file = /etc/postfix/dh_512.pem
480 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
482 The smtpd_starttls_timeout parameter limits the time of Postfix SMTP server
483 write and read operations during TLS startup and shutdown handshake procedures.
487 /etc/postfix/main.cf:
488 smtpd_starttls_timeout = 300s
490 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
492 Topics covered in this section:
494 * Client-side certificate and private key configuration
495 * Client-side TLS activity logging
496 * Client-side TLS session cache
497 * Enabling TLS in the Postfix SMTP client
498 * Requiring TLS encryption
499 * Disabling server certificate verification
500 * Per-site TLS policies
501 * Closing a DNS loophole with per-site TLS policies
502 * Discovering servers that support TLS
503 * Server certificate verification depth
504 * Client-side cipher controls
505 * Miscellaneous client controls
507 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
509 During TLS startup negotiation the Postfix SMTP client may present a
510 certificate to the remote SMTP server. The Netscape client is rather clever
511 here and lets the user select between only those certificates that match CA
512 certificates offered by the remote SMTP server. As the Postfix SMTP client uses
513 the "SSL_connect()" function from the OpenSSL package, this is not possible and
514 we have to choose just one certificate. So for now the default is to use _no_
515 certificate and key unless one is explicitly specified here.
517 Both RSA and DSA certificates are supported. You can have both at the same
518 time, in which case the cipher used determines which certificate is presented.
520 It is possible for the Postfix SMTP client to use the same key/certificate pair
521 as the Postfix SMTP server. If a certificate is to be presented, it must be in
522 "pem" format. The private key must not be encrypted, meaning: it must be
523 accessible without password. Both parts (certificate and private key) may be in
526 In order for remote SMTP servers to verify the Postfix SMTP client
527 certificates, the CA certificate (in case of a certificate chain, all CA
528 certificates) must be available. You should add these certificates to the
529 client certificate, the client certificate first, then the issuing CA(s).
531 Example: the certificate for "client.example.com" was issued by "intermediate
532 CA" which itself has a certificate of "root CA". Create the client.pem file
535 % 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
537 A Postfix SMTP client certificate supplied here must be usable as SSL client
538 certificate and hence pass the "openssl verify -purpose sslclient ..." test.
540 A server that trusts the root CA has a local copy of the root CA certificate,
541 so it is not necessary to include the root CA certificate here. Leaving it out
542 of the "client.pem" file reduces the overhead of the TLS exchange.
544 If you want the Postfix SMTP client to accept remote SMTP server certificates
545 issued by these CAs, append the root certificate to $smtp_tls_CAfile or install
546 it in the $smtp_tls_CApath directory. When you configure trust in a root CA, it
547 is not necessary to explicitly trust intermediary CAs signed by the root CA,
548 unless $smtp_tls_scert_verifydepth is less than the number of CAs in the
549 certificate chain for the servers of interest. With a verify depth of 1 you can
550 only verify certificates directly signed by a trusted CA, and all trusted
551 intermediary CAs need to be configured explicitly. With a verify depth of 2 you
552 can verify servers signed by a root CA or a direct intermediary CA (so long as
553 the server is correctly configured to supply its intermediate CA certificate).
555 RSA key and certificate examples:
557 /etc/postfix/main.cf:
558 smtp_tls_cert_file = /etc/postfix/client.pem
559 smtp_tls_key_file = $smtp_tls_cert_file
561 Their DSA counterparts:
563 /etc/postfix/main.cf:
564 smtp_tls_dcert_file = /etc/postfix/client-dsa.pem
565 smtp_tls_dkey_file = $smtp_tls_dcert_file
567 To verify a remote SMTP server certificate, the Postfix SMTP client needs to
568 trust the certificates of the issuing certification authorities. These
569 certificates in "pem" format can be stored in a single $smtp_tls_CAfile or in
570 multiple files, one CA per file in the $smtp_tls_CApath directory. If you use a
571 directory, don't forget to create the necessary "hash" links with:
573 # $
\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
575 The $smtp_tls_CAfile contains the CA certificates of one or more trusted CAs.
576 The file is opened (with root privileges) before Postfix enters the optional
577 chroot jail and so need not be accessible from inside the chroot jail.
579 Additional trusted CAs can be specified via the $smtp_tls_CApath directory, in
580 which case the certificates are read (with $mail_owner privileges) from the
581 files in the directory when the information is needed. Thus, the
582 $smtp_tls_CApath directory needs to be accessible inside the optional chroot
585 The choice between $smtp_tls_CAfile and $smtp_tls_CApath is a space/time
586 tradeoff. If there are many trusted CAs, the cost of preloading them all into
587 memory may not pay off in reduced access time when the certificate is needed.
591 /etc/postfix/main.cf:
592 smtp_tls_CAfile = /etc/postfix/CAcert.pem
593 smtp_tls_CApath = /etc/postfix/certs
595 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
597 To get additional information about Postfix SMTP client TLS activity you can
598 increase the loglevel from 0..4. Each logging level also includes the
599 information that is logged at a lower logging level.
601 0 Disable logging of TLS activity.
603 1 Log TLS handshake and certificate information.
605 2 Log levels during TLS negotiation.
607 3 Log hexadecimal and ASCII dump of TLS negotiation process
609 4 Log hexadecimal and ASCII dump of complete transmission after STARTTLS
613 /etc/postfix/main.cf:
614 smtp_tls_loglevel = 0
616 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
618 The remote SMTP server and the Postfix SMTP client negotiate a session, which
619 takes some computer time and network bandwidth. By default, this session
620 information is cached only in the smtp(8) process actually using this session
621 and is lost when the process terminates. To share the session information
622 between multiple smtp(8) processes, a persistent session cache can be used. You
623 can specify any database type that can store objects of several kbytes and that
624 supports the sequence operator. DBM databases are not suitable because they can
625 only store small objects. The cache is maintained by the tlsmgr(8) process, so
626 there is no problem with concurrent access. Session caching is highly
627 recommended, because the cost of repeatedly negotiating TLS session keys is
628 high. Future Postfix SMTP servers may limit the number of sessions that a
629 client is allowed to negotiate per unit time.
633 /etc/postfix/main.cf:
634 smtp_tls_session_cache_database = btree:/etc/postfix/smtp_scache
636 As of version 2.5, Postfix will no longer maintain this file in a directory
637 with non-Postfix ownership. As a migration aid, attempts to open such files are
638 redirected to the Postfix-owned $data_directory, and a warning is logged.
640 Cached Postfix SMTP client session information expires after a certain amount
641 of time. Postfix/TLS does not use the OpenSSL default of 300s, but a longer
642 time of 3600s (=1 hour). RFC 2246 recommends a maximum of 24 hours.
646 /etc/postfix/main.cf:
647 smtp_tls_session_cache_timeout = 3600s
649 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 c
\bcl
\bli
\bie
\ben
\bnt
\bt
651 By default, TLS is disabled in the Postfix SMTP client, so no difference to
652 plain Postfix is visible. If you enable TLS, the Postfix SMTP client will send
653 STARTTLS when TLS support is announced by the remote SMTP server.
655 When the server accepts the STARTTLS command, but the subsequent TLS handshake
656 fails, and no other server is available, the Postfix SMTP client defers the
657 delivery attempt, and the mail stays in the queue. After a handshake failure,
658 the communications channel is in an indeterminate state and cannot be used for
663 /etc/postfix/main.cf:
666 R
\bRe
\beq
\bqu
\bui
\bir
\bri
\bin
\bng
\bg T
\bTL
\bLS
\bS e
\ben
\bnc
\bcr
\bry
\byp
\bpt
\bti
\bio
\bon
\bn
668 You can ENFORCE the use of TLS, so that the Postfix SMTP client will not
669 deliver mail over unencrypted connections. In this mode, the remote SMTP server
670 hostname must match the information in the remote server certificate, and the
671 server certificate must be issued by a CA that is trusted by the Postfix SMTP
672 client. If the remote server certificate doesn't verify or the remote SMTP
673 server hostname doesn't match, and no other server is available, the delivery
674 attempt is deferred and the mail stays in the queue.
676 The remote SMTP server hostname is verified against all names provided as
677 dNSNames in the SubjectAlternativeName. If no dNSNames are specified, the
678 CommonName is checked. Verification may be turned off with the
679 smtp_tls_enforce_peername option which is discussed below.
681 Enforcing the use of TLS is useful if you know that you will only connect to
682 servers that support RFC 2487 _and_ that present server certificates that meet
683 the above requirements. An example would be a client only sends email to one
684 specific mailhub that offers the necessary STARTTLS support.
688 /etc/postfix/main.cf:
689 smtp_enforce_tls = yes
691 D
\bDi
\bis
\bsa
\bab
\bbl
\bli
\bin
\bng
\bg 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
693 As of RFC 2487 the requirements for hostname checking for MTA clients are not
694 set. When TLS is required (smtp_enforce_tls = yes), the option
695 smtp_tls_enforce_peername can be set to "no" to disable strict remote SMTP
696 server hostname checking. In this case, the mail delivery will proceed
697 regardless of the CommonName etc. listed in the certificate.
699 Despite the potential for eliminating "man-in-the-middle" and other attacks,
700 mandatory certificate/peername verification is not viable as a default Internet
701 mail delivery policy at this time. A significant fraction of TLS enabled MTAs
702 uses self-signed certificates, or certificates that are signed by a private
703 certificate authority. On a machine that delivers mail to the Internet, if you
704 set smtp_enforce_tls = yes, you should probably also set
705 smtp_tls_enforce_peername = no. You can use the per-site TLS policies (see
706 below) to enable full peer verification for specific destinations that are
707 known to have verifiable TLS server certificates.
711 /etc/postfix/main.cf:
712 smtp_enforce_tls = yes
713 smtp_tls_enforce_peername = no
715 P
\bPe
\ber
\br-
\b-s
\bsi
\bit
\bte
\be T
\bTL
\bLS
\bS p
\bpo
\bol
\bli
\bic
\bci
\bie
\bes
\bs
717 A small fraction of servers offer STARTTLS but the negotiation consistently
718 fails, leading to mail aging out of the queue and bouncing back to the sender.
719 In such cases, you can use the per-site policies to disable TLS for the problem
720 sites. Alternatively, you can enable TLS for just a few specific sites and not
721 enable it for all sites.
723 The smtp_tls_per_site table is searched for a policy that matches the following
726 remote SMTP server hostname
727 This is simply the DNS name of the server that the Postfix SMTP client
728 connects to; this name may be obtained from other DNS lookups, such as
729 MX lookups or CNAME lookups.
731 This is normally the domain portion of the recipient address, but it
732 may be overruled by information from the transport(5) table, from the
733 relayhost parameter setting, or from the relay_transport setting. When
734 it's not the recipient domain, the next-hop destination can have the
735 Postfix-specific form "[name]", [name]:port", "name" or "name:port".
737 When both the hostname lookup and the next-hop lookup succeed, the host policy
738 does not automatically override the next-hop policy. Instead, precedence is
739 given to either the more specific or the more secure per-site policy as
742 The smtp_tls_per_site table uses a simple "name whitespace value" format.
743 Specify host names or next-hop destinations on the left-hand side; no wildcards
744 are allowed. On the right hand side specify one of the following keywords:
747 Don't use TLS at all. This overrides a less specific M
\bMA
\bAY
\bY lookup result
748 from the alternate host or next-hop lookup key, and overrides the
749 global smtp_use_tls, smtp_enforce_tls, and smtp_tls_enforce_peername
752 Try to use TLS if the server announces support, otherwise use the
753 unencrypted connection. This has less precedence than a more specific
754 result (including N
\bNO
\bON
\bNE
\bE) from the alternate host or next-hop lookup key,
755 and has less precedence than the more specific global "smtp_enforce_tls
756 = yes" or "smtp_tls_enforce_peername = yes".
758 Require TLS encryption, but do not require that the remote SMTP server
759 hostname matches the information in the remote SMTP server certificate,
760 or that the server certificate was issued by a trusted CA. This
761 overrides a less secure N
\bNO
\bON
\bNE
\bE or a less specific M
\bMA
\bAY
\bY lookup result from
762 the alternate host or next-hop lookup key, and overrides the global
763 smtp_use_tls, smtp_enforce_tls and smtp_tls_enforce_peername settings.
765 Require TLS encryption, require that the remote SMTP server hostname
766 matches the information in the remote SMTP server certificate, and
767 require that the remote SMTP server certificate was issued by a trusted
768 CA. This overrides a less secure N
\bNO
\bON
\bNE
\bE and M
\bMU
\bUS
\bST
\bT_
\b_N
\bNO
\bOP
\bPE
\bEE
\bER
\bRM
\bMA
\bAT
\bTC
\bCH
\bH or a less
769 specific M
\bMA
\bAY
\bY lookup result from the alternate host or next-hop lookup
770 key, and overrides the global smtp_use_tls, smtp_enforce_tls and
771 smtp_tls_enforce_peername settings.
773 The precedences between global (main.cf) and per-site TLS policies can be
774 summarized as follows:
776 * When neither the remote SMTP server hostname nor the next-hop destination
777 are found in the smtp_tls_per_site table, the policy is based on
778 smtp_use_tls, smtp_enforce_tls and smtp_tls_enforce_peername. Note:
779 "smtp_enforce_tls = yes" and "smtp_tls_enforce_peername = yes" imply
780 "smtp_use_tls = yes".
782 * When both hostname and next-hop destination lookups produce a result, the
783 more specific per-site policy (NONE, MUST, etc) overrides the less specific
784 one (MAY), and the more secure per-site policy (MUST, etc) overrides the
785 less secure one (NONE).
787 * After the per-site policy lookups are combined, the result generally
788 overrides the global policy. The exception is the less specific M
\bMA
\bAY
\bY per-
789 site policy, which is overruled by the more specific global
790 "smtp_enforce_tls = yes" with server certificate verification as specified
791 with the smtp_tls_enforce_peername parameter.
793 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 p
\bpe
\ber
\br-
\b-s
\bsi
\bit
\bte
\be T
\bTL
\bLS
\bS p
\bpo
\bol
\bli
\bic
\bci
\bie
\bes
\bs
795 As long as no secure DNS lookup mechanism is available, false hostnames in MX
796 or CNAME responses can change the server hostname that Postfix uses for TLS
797 policy lookup and server certificate verification. Even with a perfect match
798 between the server hostname and the server certificate, there is no guarantee
799 that Postfix is connected to the right server. To avoid this loophole take the
802 * Eliminate MX lookups. Specify local transport(5) table entries for
803 sensitive domains with explicit smtp:[mailhost] or smtp:[mailhost]:port
804 destinations (you can assure security of this table unlike DNS); in the
805 smtp_tls_per_site table specify the value M
\bMU
\bUS
\bST
\bT for the key [mailhost] or
806 smtp:[mailhost]:port. This prevents false hostname information in DNS MX
807 records from changing the server hostname that Postfix uses for TLS policy
808 lookup and server certificate verification.
810 * Disallow CNAME hostname overrides. In main.cf specify
811 "smtp_cname_overrides_servername = no". This prevents false hostname
812 information in DNS CNAME records from changing the server hostname that
813 Postfix uses for TLS policy lookup and server certificate verification.
814 This feature requires Postfix 2.2.9 or later.
818 /etc/postfix/main.cf:
819 smtp_tls_per_site = hash:/etc/postfix/tls_per_site
820 relayhost = [msa.example.net]:587
822 /etc/postfix/tls_per_site:
823 # relayhost exact nexthop match
824 [msa.example.net]:587 MUST
826 # TLS should not be used with the example.org MX hosts.
829 # TLS should not be used with the host smtp.example.com.
830 smtp.example.com NONE
832 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
834 As we decide on a "per site" basis whether or not to use TLS, it would be good
835 to have a list of sites that offered "STARTTLS". We can collect it ourselves
838 If the smtp_tls_note_starttls_offer feature is enabled and a server offers
839 STARTTLS while TLS is not already enabled for that server, the Postfix SMTP
840 client logs a line as follows:
842 postfix/smtp[pid]: Host offered STARTTLS: [hostname.example.com]
846 /etc/postfix/main.cf:
847 smtp_tls_note_starttls_offer = yes
849 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
851 When verifying a remote SMTP server certificate, a verification depth of 1 is
852 sufficient if the certificate is directly issued by a CA specified with
853 smtp_tls_CAfile or smtp_tls_CApath. The default value of 5 should also suffice
854 for longer chains (root CA issues special CA which then issues the actual
859 /etc/postfix/main.cf:
860 smtp_tls_scert_verifydepth = 5
862 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
864 To influence the Postfix SMTP client cipher selection scheme, you can give
865 cipherlist string. A detailed description would go to far here; please refer to
866 the OpenSSL documentation. If you don't know what to do with it, simply don't
867 touch it and leave the (openssl-)compiled in default!
869 DO NOT USE " to enclose the string, specify just the string!!!
873 /etc/postfix/main.cf:
874 smtp_tls_cipherlist = DEFAULT
876 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
878 The smtp_starttls_timeout parameter limits the time of Postfix SMTP client
879 write and read operations during TLS startup and shutdown handshake procedures.
880 In case of problems the Postfix SMTP client tries the next network address on
881 the mail exchanger list, and defers delivery if no alternative server is
886 /etc/postfix/main.cf:
887 smtp_starttls_timeout = 300s
889 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
891 The security of cryptographic software such as TLS depends critically on the
892 ability to generate unpredictable numbers for keys and other information. To
893 this end, the tlsmgr(8) process maintains a Pseudo Random Number Generator
894 (PRNG) pool. This is queried by the smtp(8) and smtpd(8) processes when they
895 initialize. By default, these daemons request 32 bytes, the equivalent to 256
896 bits. This is more than sufficient to generate a 128bit (or 168bit) session
901 /etc/postfix/main.cf:
902 tls_daemon_random_bytes = 32
904 In order to feed its in-memory PRNG pool, the tlsmgr(8) reads entropy from an
905 external source, both at startup and during run-time. Specify a good entropy
906 source, like EGD or /dev/urandom; be sure to only use non-blocking sources (on
907 OpenBSD, use /dev/arandom when tlsmgr(8) complains about /dev/urandom timeout
908 errors). If the entropy source is not a regular file, you must prepend the
909 source type to the source name: "dev:" for a device special file, or "egd:" for
910 a source with EGD compatible socket interface.
912 Examples (specify only one in main.cf):
914 /etc/postfix/main.cf:
915 tls_random_source = dev:/dev/urandom
916 tls_random_source = egd:/var/run/egd-pool
918 By default, tlsmgr(8) reads 32 bytes from the external entropy source at each
919 seeding event. This amount (256bits) is more than sufficient for generating a
920 128bit symmetric key. With EGD and device entropy sources, the tlsmgr(8) limits
921 the amount of data read at each step to 255 bytes. If you specify a regular
922 file as entropy source, a larger amount of data can be read.
926 /etc/postfix/main.cf:
927 tls_random_bytes = 32
929 In order to update its in-memory PRNG pool, the tlsmgr(8) queries the external
930 entropy source again after a pseudo-random amount of time. The time is
931 calculated using the PRNG, and is between 0 and the maximal time specified with
932 tls_random_reseed_period. The default maximal time interval is 1 hour.
936 /etc/postfix/main.cf:
937 tls_random_reseed_period = 3600s
939 The tlsmgr(8) process saves the PRNG state to a persistent exchange file at
940 regular times and when the process terminates, so that it can recover the PRNG
941 state the next time it starts up. This file is created when it does not exist.
942 Its default location is under the Postfix configuration directory, which is not
943 the proper place for information that is modified by Postfix. Instead, the file
944 location should probably be on the /var partition (but n
\bno
\bot
\bt inside the chroot
949 /etc/postfix/main.cf:
950 tls_random_exchange_name = /etc/postfix/prng_exch
951 tls_random_prng_update_period = 3600s
953 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
955 The following steps will get you started quickly. Because you sign your own
956 Postfix public key certificate, you get TLS encryption but no TLS
957 authentication. This is sufficient for testing, and for exchanging email with
958 sites that you have no trust relationship with. For real authentication, your
959 Postfix public key certificate needs to be signed by a recognized Certificate
960 Authority, and Postfix needs to be configured with a list of public key
961 certificates of Certificate Authorities, so that Postfix can verify the public
962 key certificates of remote hosts.
964 In the examples below, user input is shown in b
\bbo
\bol
\bld
\bd font, and a "#" prompt
965 indicates a super-user shell.
967 * Become your own Certificate Authority, so that you can sign your own public
968 keys. This example uses the CA.pl script that ships with OpenSSL. By
969 default, OpenSSL installs this as /usr/local/ssl/misc/CA.pl, but your
970 mileage may vary. The script creates a private key in ./demoCA/private/
971 cakey.pem and a public key in ./demoCA/cacert.pem.
973 % /
\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
974 CA certificate filename (or enter to create)
976 Making CA certificate ...
977 Using configuration from /etc/ssl/openssl.cnf
978 Generating a 1024 bit RSA private key
979 ....................++++++
981 writing new private key to './demoCA/private/cakey.pem'
982 Enter PEM pass phrase:w
\bwh
\bha
\bat
\bte
\bev
\bve
\ber
\br
984 * Create an unpassworded private key for host FOO and create an unsigned
985 public key certificate.
987 % 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
989 Using configuration from /etc/ssl/openssl.cnf
990 Generating a 1024 bit RSA private key
991 ........................................++++++
993 writing new private key to 'FOO-key.pem'
995 You are about to be asked to enter information that will be
997 into your certificate request.
998 What you are about to enter is what is called a Distinguished Name or a
1000 There are quite a few fields but you can leave some blank
1001 For some fields there will be a default value,
1002 If you enter '.', the field will be left blank.
1004 Country Name (2 letter code) [AU]:U
\bUS
\bS
1005 State or Province Name (full name) [Some-State]:N
\bNe
\bew
\bw Y
\bYo
\bor
\brk
\bk
1006 Locality Name (eg, city) []:W
\bWe
\bes
\bst
\btc
\bch
\bhe
\bes
\bst
\bte
\ber
\br
1007 Organization Name (eg, company) [Internet Widgits Pty Ltd]:P
\bPo
\bor
\brc
\bcu
\bup
\bpi
\bin
\bne
\be
1008 Organizational Unit Name (eg, section) []:
1009 Common Name (eg, YOUR name) []:F
\bFO
\bOO
\bO
1010 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
1012 Please enter the following 'extra' attributes
1013 to be sent with your certificate request
1014 A challenge password []:w
\bwh
\bha
\bat
\bte
\bev
\bve
\ber
\br
1015 An optional company name []:
1017 * Sign the public key certificate for host FOO with the Certification
1018 Authority private key that we created a few steps ago.
1020 % 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
1021 Uing configuration from /etc/ssl/openssl.cnf
1022 Enter PEM pass phrase:w
\bwh
\bha
\bat
\bte
\bev
\bve
\ber
\br
1023 Check that the request matches the signature
1025 The Subjects Distinguished Name is as follows
1026 countryName :PRINTABLE:'US'
1027 stateOrProvinceName :PRINTABLE:'New York'
1028 localityName :PRINTABLE:'Westchester'
1029 organizationName :PRINTABLE:'Porcupine'
1030 commonName :PRINTABLE:'FOO'
1031 emailAddress :IA5STRING:'wietse@porcupine.org'
1032 Certificate is to be certified until Nov 21 19:40:56 2005 GMT (365
1034 Sign the certificate? [y/n]:y
\by
1036 1 out of 1 certificate requests certified, commit? [y/n]y
\by
1037 Write out database with 1 new entries
1040 * Install the host private key, the host public key certificate, and the
1041 Certification Authority certificate files. This requires super-user
1044 # 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
1045 # 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
1046 # 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
1048 * Configure Postfix, by adding the following to /etc/postfix/main.cf.
1050 smtp_tls_CAfile = /etc/postfix/cacert.pem
1051 smtp_tls_cert_file = /etc/postfix/FOO-cert.pem
1052 smtp_tls_key_file = /etc/postfix/FOO-key.pem
1053 smtp_tls_session_cache_database = btree:/var/run/smtp_tls_session_cache
1055 smtpd_tls_CAfile = /etc/postfix/cacert.pem
1056 smtpd_tls_cert_file = /etc/postfix/FOO-cert.pem
1057 smtpd_tls_key_file = /etc/postfix/FOO-key.pem
1058 smtpd_tls_received_header = yes
1059 smtpd_tls_session_cache_database = btree:/var/run/
1060 smtpd_tls_session_cache
1062 tls_random_source = dev:/dev/urandom
1064 R
\bRe
\bep
\bpo
\bor
\brt
\bti
\bin
\bng
\bg p
\bpr
\bro
\bob
\bbl
\ble
\bem
\bms
\bs
1066 When reporting a problem, please be thorough in the report. Patches, when
1067 possible, are greatly appreciated too.
1069 Please differentiate when possible between:
1071 * Problems in the TLS code: <postfix_tls@aet.tu-cottbus.de>
1072 * Problems in vanilla Postfix: <postfix-users@postfix.org>
1074 C
\bCo
\bom
\bmp
\bpa
\bat
\bti
\bib
\bbi
\bil
\bli
\bit
\bty
\by w
\bwi
\bit
\bth
\bh P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx <
\b<2
\b2.
\b.2
\b2 T
\bTL
\bLS
\bS s
\bsu
\bup
\bpp
\bpo
\bor
\brt
\bt
1076 Postfix version 2.2 TLS support is based on the Postfix/TLS patch by Lutz
1077 Jänicke, but differs in a few minor ways.
1079 * main.cf: Specify "btree" instead of "sdbm" for TLS session cache databases.
1081 TLS session cache databases are now accessed only by the tlsmgr(8) process,
1082 so there are no more concurrency issues. Although Postfix has an sdbm
1083 client, the sdbm library (1000 lines of code) is not included with Postfix.
1085 TLS session caches can use any database that can store objects of several
1086 kbytes or more, and that implements the sequence operation. In most cases,
1087 btree databases should be adequate.
1089 NOTE: You cannot use dbm databases. TLS session objects are too large.
1091 * master.cf: Specify "unix" instead of "fifo" as the tlsmgr service type.
1093 The smtp(8) and smtpd(8) processes now use a client-server protocol in
1094 order to access the tlsmgr(8) pseudo-random number generation (PRNG) pool,
1095 and in order to access the TLS session cache databases. Such a protocol
1096 cannot be run across fifos.
1098 * smtp_tls_per_site: the MUST_NOPEERMATCH per-site policy cannot override the
1099 global "smtp_tls_enforce_peername = yes" setting.
1101 * smtp_tls_per_site: a combined (NONE + MAY) lookup result for (hostname and
1102 next-hop destination) produces counter-intuitive results for different
1103 main.cf settings. TLS is enabled with "smtp_tls_enforce_peername = no", but
1104 it is disabled when both "smtp_enforce_tls = yes" and
1105 "smtp_tls_enforce_peername = yes".
1107 The smtp_tls_per_site limitations were removed by the end of the Postfix 2.2
1110 C
\bCr
\bre
\bed
\bdi
\bit
\bts
\bs
1112 * TLS support for Postfix was originally developed by Lutz Jänicke at Cottbus
1113 Technical University.
1114 * Wietse Venema adopted the code, did some restructuring, and compiled this
1115 part of the documentation from Lutz's documents.
1116 * Victor Duchovni was instrumental with the re-implementation of the
1117 smtp_tls_per_site code in terms of enforcement levels, which simplified the
1118 implementation greatly.