Postfix 收到“需要 TLS,但主机未提供”

Postfix 收到“需要 TLS,但主机未提供”

我搜索了每个论坛、每篇文章、每个 serverfault.com 帖子以查找此问题。我正在使用全新的 Postfix 设置。它由 Virtualmin 管理。每当我尝试通过 TLS 发送邮件时,我都会收到错误 (已删除可识别信息):

Sep  7 21:58:37 mail postfix/smtp[220916]: initializing the client-side TLS engine
Sep  7 21:58:37 mail postfix/tlsmgr[220917]: open smtpd TLS cache btree:/var/lib/postfix/smtpd_scache
Sep  7 21:58:38 mail postfix/tlsmgr[220917]: open smtp TLS cache btree:/var/lib/postfix/smtp_scache
Sep  7 21:58:38 mail postfix/tlsmgr[220917]: tlsmgr_cache_run_event: start TLS smtpd session cache cleanup
Sep  7 21:58:38 mail postfix/tlsmgr[220917]: tlsmgr_cache_run_event: start TLS smtp session cache cleanup
Sep  7 21:58:38 mail postfix/smtp[220918]: initializing the client-side TLS engine
Sep  7 21:58:38 mail postfix/smtp[220918]: 536A837552: TLS is required, but was not offered by host gmail-smtp-in.l.google.com[173.194.219.27]
Sep  7 21:58:38 mail postfix/smtp[220916]: E9C5637920: to=<[email protected]>, relay=ts11-do.checktls.com[165.227.190.238]:25, delay=3768, delays=3768/0.67/0.11/0, dsn=4.7.4, status=deferred (TLS is required, but was not offered by host ts11-do.checktls.com[165.227.190.238])
Sep  7 21:58:38 mail postfix/smtp[220918]: 536A837552: TLS is required, but was not offered by host alt1.gmail-smtp-in.l.google.com[172.217.197.27]
Sep  7 21:58:38 mail postfix/smtp[220918]: 536A837552: TLS is required, but was not offered by host alt2.gmail-smtp-in.l.google.com[108.177.12.27]
Sep  7 21:58:39 mail postfix/smtp[220918]: 536A837552: TLS is required, but was not offered by host alt3.gmail-smtp-in.l.google.com[64.233.186.27]
Sep  7 21:58:39 mail postfix/smtp[220918]: 536A837552: to=<[email protected]>, relay=alt4.gmail-smtp-in.l.google.com[209.85.202.27]:25, delay=3819, delays=3817/0.67/1.2/0, dsn=4.7.4, status=deferred (TLS is required, but was not offered by host alt4.gmail-smtp-in.l.google.com[209.85.202.27])
Sep  7 22:00:01 mail postfix/pickup[220911]: A9D8537D1D: uid=33 from=<www-data>
Sep  7 22:00:01 mail postfix/cleanup[221006]: A9D8537D1D: message-id=<[email protected]>

我正在使用 letsencrypt(使用 Virtualmin 提取)来获取我的证书。它将证书放在 /home/user/ssl 中。*这是我的 main.cf(域名替换为 example.com):

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
allow_percent_hack = no
append_dot_mydomain = no
biff = no
broken_sasl_auth_clients = yes
home_mailbox = Maildir/
inet_protocols = ipv4
mailbox_command = /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME
mailbox_size_limit = 0
milter_default_action = accept
mydomain = EXAMPLE.com
myhostname = mail.EXAMPLE.com
mynetworks_style = subnet
non_smtpd_milters = inet:localhost:8891
recipient_delimiter = +
sender_bcc_maps = hash:/etc/postfix/bcc
sender_dependent_default_transport_maps = hash:/etc/postfix/dependent
smtp_dns_support_level = dnssec
smtp_host_lookup = dns
smtp_tls_ciphers = high
smtp_tls_exclude_ciphers = MD5, DES, ADH, RC4, PSD, SRP, 3DES, eNULL, aNULL
smtp_tls_loglevel = 4
smtp_tls_mandatory_ciphers = high
smtp_tls_mandatory_exclude_ciphers = MD5, DES, ADH, RC4, PSD, SRP, 3DES, eNULL, aNULL
smtp_tls_mandatory_protocols = TLSv1.3,TLSv1.2,TLSv1.1,!TLSv1,!SSLv2,!SSLv3
smtp_tls_note_starttls_offer = yes
smtp_tls_protocols = TLSv1.3, TLSv1.2, TLSv1.1, !TLSv1, !SSLv2, !SSLv3
smtp_tls_security_level = encrypt
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_milters = inet:localhost:8891
smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination check_policy_service inet:127.0.0.1:10023
smtpd_relay_restrictions = ${{$compatibility_level} < {1} ? {} : {permit_mynetworks permit_sasl_authenticated defer_unauth_destination}}
smtpd_sasl_auth_enable = yes
smtpd_tls_ask_ccert = yes
smtpd_tls_cert_file=/home/EXAMPLE/ssl.cert
smtpd_tls_ciphers = high
smtpd_tls_exclude_ciphers = MD5, DES, ADH, RC4, PSD, SRP, 3DES, eNULL, aNULL
smtpd_tls_key_file=/home/EXAMPLE/ssl.key
smtpd_tls_loglevel = 4
smtpd_tls_mandatory_ciphers = high
smtpd_tls_mandatory_exclude_ciphers = MD5, DES, ADH, RC4, PSD, SRP, 3DES, eNULL, aNULL
smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3, !TLSv1, TLSv1.1, TLSv1.2, TLSv1.3
smtpd_tls_protocols = TLSv1.3, TLSv1.2, TLSv1.1, !TLSv1, !SSLv2, !SSLv3
smtpd_tls_received_header = yes
smtpd_tls_security_level = encrypt
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
tls_preempt_cipherlist = yes
tls_random_source = dev:/dev/urandom
tls_server_sni_maps = hash:/etc/postfix/sni_map
virtual_alias_maps = hash:/etc/postfix/virtual
virtual_alias_domains = $mydomain

我知道 ENCRYPT 会强制使用 TLS - 使用 MAY 会退回到非 TLS 连接,这是为了测试

这是我的master.cf

smtp      inet  n       -       n       -       -       smtpd
pickup    unix  n       -       n       60      1       pickup
cleanup   unix  n       -       n       -       0       cleanup
qmgr      unix  n       -       n       300     1       qmgr
#qmgr     unix  n       -       n       300     1       oqmgr
tlsmgr    unix  -       -       n       1000?   1       tlsmgr
rewrite   unix  -       -       n       -       -       trivial-rewrite
bounce    unix  -       -       n       -       0       bounce
defer     unix  -       -       n       -       0       bounce
trace     unix  -       -       n       -       0       bounce
verify    unix  -       -       n       -       1       verify
flush     unix  n       -       n       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       n       -       -       smtp
relay     unix  -       -       n       -       -       smtp
        -o syslog_name=postfix/$service_name
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       n       -       -       showq
error     unix  -       -       n       -       -       error
retry     unix  -       -       n       -       -       error
discard   unix  -       -       n       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       n       -       -       lmtp
anvil     unix  -       -       n       -       1       anvil
scache    unix  -       -       n       -       1       scache
postlog   unix-dgram n  -       n       -       1       postlogd

*** 我将配置恢复为默认设置,希望有帮助,但没有变化。

当我通过 telnet 进入我的服务器时,我得到了 starttls 选项:

Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
220 mail.EXAMPLE.com ESMTP Postfix
EHLO example.com
250-mail.EXAMPLE.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250 CHUNKING

我正在使用 opnsense 作为防火墙。我认为它不会使用 SMTP 检查来阻止 TLS。

将设置设为 MAY 而不是 ENCRYPT 后,我可以正常发送和接收电子邮件。将其设为 MAY 后,Google 和 checktls.com 报告未使用 TLS。

dmarc、spf 等的所有测试结果都很好。这是在 Ubuntu 服务器 20 上运行的 postfix(最新版本)。

我的环境:

  • 数据中心内的共置服务器(对其没有限制)
  • Proxmox,截至 9/8/21 的最新状态
  • 该容器在 LXC、Ubuntu 20 中运行
  • 容器位于 OPNSense 防火墙后面
  • 基于 Web 的测试显示服务器提供 starttls
  • 从服务器运行 telnet > 另一台服务器确实显示 starttls 作为选项

非常感谢您的帮助,谢谢。

答案1

在 serverfault 所有人的帮助下,我深入研究了这个问题,发现我的主机确实阻止了 TLS。在与我的主机交谈并被告知他们不过滤 SMTP 后,他们终于承认过滤了 SMTP。

我通过在另一台主机上设置 VPS 中继服务器解决了这个问题。我的主服务器现在通过非标准端口上的中继发送邮件。通过此设置,我可以发送安全电子邮件,而无需主机对其进行过滤。

再次感谢您的帮助。

相关内容