2016-04-15 19:02:41 +00:00
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
2020-05-10 14:03:30 +00:00
smtpd_banner = $ myhostname ESMTP
2016-04-15 19:02:41 +00:00
biff = no
append_dot_mydomain = no
readme_directory = no
# Basic configuration
2017-01-25 13:10:40 +00:00
# myhostname =
2018-04-23 18:35:33 +00:00
alias_maps = hash : / etc / aliases
alias_database = hash : / etc / aliases
mydestination = $ myhostname , localhost . $ mydomain , localhost
2017-01-25 13:10:40 +00:00
relayhost =
2016-08-21 20:10:13 +00:00
mynetworks = 127.0 . 0.0 / 8 [ : : 1 ] / 128 [ fe80 :: ] / 64
2016-04-15 19:02:41 +00:00
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
# TLS parameters
Dual certificate support (eg ECDSA with RSA fallback) (#1801)
* feat: Change Postfix smtpd_tls key and cert files to chain_files
Since Postfix 3.4, `smtpd_tls_cert_file` and `smtpd_tls_key_file` have been deprecated in favor of `smtpd_tls_chain_files` which supports a list of values where a single or sequence of file paths provide a private key followed by it's certificate chain.
* feat: Dual certificate support
`smtpd_tls_chain_files` allows for multiple key+cert bundles so that you can provide different key types, such as ECDSA and RSA.
To maintain compatibility with the current CERT/KEY ENV vars only a 2nd certificate is supported.
Since Dovecot 2.2.31 a related feature is also available, but it is limited to only providing one alternative certificate via separate cert and key settings.
---
This feature enables support for multiple certificates, eg for serving modern ECDSA certs with RSA as fallback.
* chore: Refactor variable names to meet style guide
Improved some comments too.
* chore: Have function definitions respect style guide
* chore: Minor edits to comments
* chore: Expand on comments for maintenance, alert of insecure config
When `SSL_TYPE` isn't properly setup, we're still offering SSL connections but not warning in logs about the insecurity of such, or why a misconfiguration may have occurred.
This commit more clearly communicates to the user that they should look into the issue before considering deploying to production.
The `TODO` comments communicate to any future maintainer to consider treating these improper configs as disabling TLS instead.
* fix: Use `snakeoil` cert
I mistakenly thought this was placeholder text, which broke some tests. This adds the two files in the correct order (private key followed by cert/chain), to fix that issue.
* fix: Disable alt cert for Dovecot if necessary
Certain scenarios may persist state of previously configured alt cert via ENV vars that are removed from a future run. If the config is not reset to original immutable state, this will correctly disable the config from using alt cert unintentionally.
* fix: Satisfy ShellCheck lint
By switching from string var to array / list expansion, this better stores the extracted result and applies it in a manner that ShellCheck linting approves, removing the need to disable the rule.
* feat: Support dual cert test
Few tweaks to the test script allows re-purposing it for covering dual cert support as well.
* chore: Rearranged cert and key lines
A little reorganization, mostly placing private key ahead of related cert lines.
* chore: Refactor `_set_certificate`
This should make the parameters a little less confusing.
Previously was 3 parameters, but the Postfix parameter (1st) may look like two variables if you don't pay attention to the surrounding quotes; while the Dovecot parameters (2nd + 3rd) would have an opposing order. There was also a variant where the `FULLKEYCHAIN` var was passed in three times.
Now it's two params, with the 2nd param as an optional one. If the 2nd param is provided, then the two params are in the order of private key then certificate, otherwise if only a single parameter it's a single PEM file with the full cert chain and private key bundled.
This avoids implying that Postfix and Dovecot might use different files.
* chore: Document current state of `SSL_TYPE` logic better
Inlined for the benefit of anyone else maintaining this section if I'm unable to address the concerns within my own time.
* docs: ENV vars
`TLS_LEVEL=old` isn't in the codebase anymore, not likely to be relevant to retain.
No point in documenting what is considered invalid / unsupported config value in the first place for `SSL_TYPE`.
`SSL_TYPE=manual` was missing documentation for both related file path ENV vars, they've been added along with their alt fallback variants.
* chore: Update Dovecot LMTP SSL test config
Not sure how relevant this is, the file isn't complete sync with the main dovecot `10-ssl.conf` config, adding the support just in case.
* chore: Rename `FULLKEYCHAIN` to avoid confusion
There doesn't appear to be a standardized name for this type of file bundle, and `keychain` may be misleading (fullkeychain often provides macOS keychain results on search engines).
Opting for a more explicit `KEY_WITH_FULLCHAIN` name instead.
* fix: Invalid var name
`_set_certificate` refactor commit accidentally changed a var name and committed that breaking the dual cert support (thanks tests!).
* test: Refactor `mail_ssl_manual.bats`
Proper test return values instead of `wc -l` based checking.
Tests with dual cert support active, tests that feature (to better detect failure case.
Third test case was unable to verify new self-signed certificate, added new certs signed with self-signed root CA.
Adjusted openssl `CApath` parameter to use `CAfile` instead as `letsencrypt` cert was replaced thus CA cert is missing from the system trust store.
* test: Properly check for files in `mail_ssl_manual.bats`
Fixes lint error.
Also realized I was accidentally asserting a file exists in the test environment, not within the container.
Resolved that and also added an additional test case to ensure the ENV var files are valid when passed in, in the event a change misconfigures them and that the issue is identified earlier.
* chore: Apply PR review feedback
Better format some strings that had mixed quotes when they weren't necessary.
Additionally DRYed up the config path for Postfix and Dovecot within the `_setup_ssl` method.
Co-authored-by: Georg Lauterbach <infrastructure@itbsd.com>
2021-02-21 22:43:41 +00:00
# These [snakeoil files actually exist](https://askubuntu.com/questions/396120/what-is-the-purpose-of-the-ssl-cert-snakeoil-key), but shouldn't ever be used in production!
# If no `SSL_TYPE` env is set, "plaintext" is configured, but still accepts SSL with these:
smtpd_tls_chain_files = / etc / ssl / private / ssl - cert - snakeoil . key / etc / ssl / certs / ssl - cert - snakeoil . pem
#smtpd_tls_CAfile =
#smtp_tls_CAfile =
2016-04-15 19:02:41 +00:00
smtpd_tls_security_level = may
2017-12-31 11:33:48 +00:00
smtpd_tls_loglevel = 1
2016-04-15 19:02:41 +00:00
smtp_tls_security_level = may
smtp_tls_loglevel = 1
2020-04-29 07:41:08 +00:00
# Reduces CPU overhead with `NO_COMPRESSION`, SMTP not at risk of CRIME attack (see git blame for details)
2020-05-01 22:04:05 +00:00
# Reduce opportunities for a potential CPU exhaustion attack with `NO_RENEGOTIATION`
tls_ssl_options = NO_COMPRESSION , NO_RENEGOTIATION
2020-04-29 07:41:08 +00:00
2021-02-18 09:24:34 +00:00
tls_high_cipherlist = ECDHE - ECDSA - AES128 - GCM - SHA256 : ECDHE - RSA - AES128 - GCM - SHA256 : ECDHE - ECDSA - AES256 - GCM - SHA384 : ECDHE - RSA - AES256 - GCM - SHA384 : ECDHE - ECDSA - CHACHA20 - POLY1305 : ECDHE - RSA - CHACHA20 - POLY1305 : DHE - RSA - AES128 - GCM - SHA256 : DHE - RSA - AES256 - GCM - SHA384
2017-12-31 11:33:48 +00:00
tls_preempt_cipherlist = yes
2018-03-26 18:50:28 +00:00
smtpd_tls_protocols = ! SSLv2 , ! SSLv3 , ! TLSv1 , ! TLSv1 . 1
smtp_tls_protocols = ! SSLv2 , ! SSLv3 , ! TLSv1 , ! TLSv1 . 1
2016-04-15 19:02:41 +00:00
smtpd_tls_mandatory_ciphers = high
2018-02-22 07:36:12 +00:00
smtpd_tls_mandatory_protocols = ! SSLv2 , ! SSLv3 , ! TLSv1 , ! TLSv1 . 1
2022-12-23 13:30:43 +00:00
smtpd_tls_exclude_ciphers = aNULL , SEED , CAMELLIA , RSA + AES , SHA1
2017-01-25 13:10:40 +00:00
smtpd_tls_dh1024_param_file = / etc / postfix / dhparams . pem
2016-07-25 20:50:36 +00:00
smtpd_tls_CApath = / etc / ssl / certs
smtp_tls_CApath = / etc / ssl / certs
2016-04-15 19:02:41 +00:00
2016-04-26 17:33:25 +00:00
# Settings to prevent SPAM early
smtpd_helo_required = yes
smtpd_delay_reject = yes
2016-04-27 07:44:21 +00:00
smtpd_helo_restrictions = permit_mynetworks , reject_invalid_helo_hostname , permit
2016-04-26 17:33:25 +00:00
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
2023-02-10 23:24:09 +00:00
smtpd_recipient_restrictions = permit_sasl_authenticated , permit_mynetworks , reject_unauth_destination , check_policy_service unix : private / policyd - spf , reject_unauth_pipelining , reject_invalid_helo_hostname , reject_non_fqdn_helo_hostname , reject_unknown_recipient_domain
2016-04-26 17:33:25 +00:00
smtpd_client_restrictions = permit_mynetworks , permit_sasl_authenticated , reject_unauth_destination , reject_unauth_pipelining
2023-03-03 14:55:32 +00:00
smtpd_sender_restrictions = $ dms_smtpd_sender_restrictions
2018-01-25 07:32:00 +00:00
disable_vrfy_command = yes
2016-04-26 17:33:25 +00:00
2023-03-03 14:55:32 +00:00
# Custom defined parameters for DMS:
dms_smtpd_sender_restrictions = permit_sasl_authenticated , permit_mynetworks , reject_unknown_sender_domain , reject_unknown_client_hostname
# Submission ports 587 and 465 support for SPOOF_PROTECTION=1
mua_sender_restrictions = reject_authenticated_sender_login_mismatch , $ dms_smtpd_sender_restrictions
Introducing Postscreen (#799)
* Introduced Postscreen
cheaper, earlier and simpler blocking of zombies/spambots.
From http://postfix.cs.utah.edu/POSTSCREEN_README.html :
As a first layer, postscreen(8) blocks connections from zombies and other spambots that are responsible for about 90% of all spam. It is implemented as a single process to make this defense as cheap as possible.
Things we need to consider:
- Do we need a whitelist/backlist file? (http://postfix.cs.utah.edu/postconf.5.html#postscreen_access_list)
- Via introducing an optional config/postfix-access.cidr
- The only permanent whitelisting I could imagine are monitoring services(which might (still?) behave weird/hastely) or blacklisting backup servers(since no traffic should be coming from them anyway)
- Do we need deep inspections? They are desireable, but these tests are expensive: a good client must disconnect after it passes the test, before it can talk to a real Postfix SMTP server. Considered tests are:
- postscreen_bare_newline_enable (http://postfix.cs.utah.edu/postconf.5.html#postscreen_bare_newline_action)
- postscreen_non_smtp_command_enable (http://postfix.cs.utah.edu/postconf.5.html#postscreen_non_smtp_command_action)
- postscreen_pipelining_enable (http://postfix.cs.utah.edu/postconf.5.html#postscreen_pipelining_action)
- Do we need to make the blacklisting via dnsblocking configurable? It's currently set and weighted as follows, where a score of 3 results in blocking, a score of -1 results in whitelisting:
(*: adds the specified weight to the SMTP client's DNSBL score. Specify a negative number for whitelisting.)
(http://postfix.cs.utah.edu/postconf.5.html#postscreen_dnsbl_sites)
- zen.spamhaus.org*3
- bl.mailspike.net
- b.barracudacentral.org*2
- bl.spameatingmonkey.net
- bl.spamcop.net
- dnsbl.sorbs.net
- psbl.surriel.com
- list.dnswl.org=127.0.[0..255].0*-2
- list.dnswl.org=127.0.[0..255].1*-3
- list.dnswl.org=127.0.[0..255].[2..3]*-4
- What to do when blacklisting? I currently set it to drop. We could
- ignore: Ignore the failure of this test. Allow other tests to complete. Repeat this test the next time the client connects. This option is useful for testing and collecting statistics without blocking mail.
- enforce: Allow other tests to complete. Reject attempts to deliver mail with a 550 SMTP reply, and log the helo/sender/recipient information. Repeat this test the next time the client connects.
- drop: Drop the connection immediately with a 521 SMTP reply. Repeat this test the next time the client connects.
In the end I think we could drop postgrey support. Postscreen replaces postgrey in its entirety, while being more selective and not delaying mail. Especially if we consider using the deep inspection options of postscreen.
Hope that wasn't too much to read! ;)
* main.cf got misformatted..
Don't know how, should be ok now.
* fixed malformatted main.cf & repaired master.cf
* reenabled rbl stuff.. It's cached, therefore doesn't hurt
* fixed tests
* added tests, repaired tests, added info, introduced new Variable POSTSCREEN_ACTION, fixes
2018-02-04 20:31:08 +00:00
# Postscreen settings to drop zombies/open relays/spam early
postscreen_dnsbl_action = enforce
2022-11-07 08:28:47 +00:00
postscreen_dnsbl_sites =
zen . spamhaus . org = 127.0 . 0 . [ 2 . . 11 ] * 3
bl . mailspike . net = 127.0 . 0 . [ 2 ; 14 ; 13 ; 12 ; 11 ; 10 ]
2022-06-05 00:10:20 +00:00
b . barracudacentral . org * 2
2022-11-07 08:28:47 +00:00
bl . spameatingmonkey . net = 127.0 . 0.2
2022-06-05 00:10:20 +00:00
dnsbl . sorbs . net
psbl . surriel . com
list . dnswl . org = 127.0 . [ 0 . . 255 ] . 0 * - 2
list . dnswl . org = 127.0 . [ 0 . . 255 ] . 1 * - 3
list . dnswl . org = 127.0 . [ 0 . . 255 ] . [ 2 . . 3 ] * - 4
2018-02-18 12:29:43 +00:00
postscreen_dnsbl_threshold = 3
postscreen_dnsbl_whitelist_threshold = - 1
Introducing Postscreen (#799)
* Introduced Postscreen
cheaper, earlier and simpler blocking of zombies/spambots.
From http://postfix.cs.utah.edu/POSTSCREEN_README.html :
As a first layer, postscreen(8) blocks connections from zombies and other spambots that are responsible for about 90% of all spam. It is implemented as a single process to make this defense as cheap as possible.
Things we need to consider:
- Do we need a whitelist/backlist file? (http://postfix.cs.utah.edu/postconf.5.html#postscreen_access_list)
- Via introducing an optional config/postfix-access.cidr
- The only permanent whitelisting I could imagine are monitoring services(which might (still?) behave weird/hastely) or blacklisting backup servers(since no traffic should be coming from them anyway)
- Do we need deep inspections? They are desireable, but these tests are expensive: a good client must disconnect after it passes the test, before it can talk to a real Postfix SMTP server. Considered tests are:
- postscreen_bare_newline_enable (http://postfix.cs.utah.edu/postconf.5.html#postscreen_bare_newline_action)
- postscreen_non_smtp_command_enable (http://postfix.cs.utah.edu/postconf.5.html#postscreen_non_smtp_command_action)
- postscreen_pipelining_enable (http://postfix.cs.utah.edu/postconf.5.html#postscreen_pipelining_action)
- Do we need to make the blacklisting via dnsblocking configurable? It's currently set and weighted as follows, where a score of 3 results in blocking, a score of -1 results in whitelisting:
(*: adds the specified weight to the SMTP client's DNSBL score. Specify a negative number for whitelisting.)
(http://postfix.cs.utah.edu/postconf.5.html#postscreen_dnsbl_sites)
- zen.spamhaus.org*3
- bl.mailspike.net
- b.barracudacentral.org*2
- bl.spameatingmonkey.net
- bl.spamcop.net
- dnsbl.sorbs.net
- psbl.surriel.com
- list.dnswl.org=127.0.[0..255].0*-2
- list.dnswl.org=127.0.[0..255].1*-3
- list.dnswl.org=127.0.[0..255].[2..3]*-4
- What to do when blacklisting? I currently set it to drop. We could
- ignore: Ignore the failure of this test. Allow other tests to complete. Repeat this test the next time the client connects. This option is useful for testing and collecting statistics without blocking mail.
- enforce: Allow other tests to complete. Reject attempts to deliver mail with a 550 SMTP reply, and log the helo/sender/recipient information. Repeat this test the next time the client connects.
- drop: Drop the connection immediately with a 521 SMTP reply. Repeat this test the next time the client connects.
In the end I think we could drop postgrey support. Postscreen replaces postgrey in its entirety, while being more selective and not delaying mail. Especially if we consider using the deep inspection options of postscreen.
Hope that wasn't too much to read! ;)
* main.cf got misformatted..
Don't know how, should be ok now.
* fixed malformatted main.cf & repaired master.cf
* reenabled rbl stuff.. It's cached, therefore doesn't hurt
* fixed tests
* added tests, repaired tests, added info, introduced new Variable POSTSCREEN_ACTION, fixes
2018-02-04 20:31:08 +00:00
postscreen_greet_action = enforce
postscreen_bare_newline_action = enforce
2016-04-15 19:02:41 +00:00
# SASL
2023-02-23 14:19:39 +00:00
smtpd_sasl_auth_enable = no
2023-03-03 22:42:55 +00:00
smtpd_sasl_path = / dev / shm / sasl - auth . sock
2016-04-15 19:02:41 +00:00
smtpd_sasl_type = dovecot
smtpd_sasl_security_options = noanonymous
2018-06-14 18:02:49 +00:00
smtpd_sasl_local_domain = $ mydomain
2016-04-15 19:02:41 +00:00
broken_sasl_auth_clients = yes
# Mail directory
2016-10-24 13:03:08 +00:00
virtual_transport = lmtp : unix : / var / run / dovecot / lmtp
2016-04-15 19:02:41 +00:00
virtual_mailbox_domains = / etc / postfix / vhost
2016-11-15 19:48:09 +00:00
virtual_mailbox_maps = texthash : / etc / postfix / vmailbox
virtual_alias_maps = texthash : / etc / postfix / virtual
2016-04-15 19:02:41 +00:00
# Milters used by DKIM
2016-10-25 06:57:08 +00:00
milter_protocol = 6
2016-04-15 19:02:41 +00:00
milter_default_action = accept
2023-01-25 09:28:59 +00:00
smtpd_milters =
non_smtpd_milters =
2017-03-14 16:21:17 +00:00
# SPF policy settings
policyd - spf_time_limit = 3600
2017-08-09 21:19:00 +00:00
2018-11-01 18:32:36 +00:00
# Header checks for content inspection on receiving
header_checks = pcre : / etc / postfix / maps / header_checks . pcre
2022-06-05 00:10:20 +00:00
# Remove unwanted headers that reveal our privacy
2017-08-09 21:19:00 +00:00
smtp_header_checks = pcre : / etc / postfix / maps / sender_header_filter . pcre
2022-06-05 00:10:20 +00:00
# The default compatibility_level is 0 - which retains legacy settings defaults:
# http://www.postfix.org/COMPATIBILITY_README.html
# If backwards-compaitibilty log messages appear, fix them by explicitly adding
# the legacy or new default value (alternatively raise the compatibility_level)
#
# TODO: The next compatibility_level is 3.6, when Postfix 3.6 is available consider
# bumping this value after taking the compaitibilty changes into account.
compatibility_level = 2