Gmail 将 Dovecot 电子邮件标记为不安全

Gmail 将 Dovecot 电子邮件标记为不安全

我以为我已经成功保护了我的 Postfix/Dovecot 电子邮件服务器。我有一个 LetsEncrypt 签名的证书,对我的域名有效。

发送和接收工作正常,但自从 Gmail 开始标记不安全的电子邮件后,从我的服务器发送的所有邮件都被标记为未加密。

Gmail 用户会看到“此邮件未加密”,如下所示:

在此处输入图片描述

在 Postfix 中main.cf,除其他设置外,我还有:

# SASL, for SMTP authentication
smtpd_sasl_type = dovecot
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_path = private/auth

# TLS, for encryption
smtpd_tls_security_level = may
smtpd_tls_auth_only = no
smtpd_tls_CAfile = /etc/letsencrypt/live/mydomain.com/chain.pem
smtpd_tls_cert_file = /etc/letsencrypt/live/mydomain.com/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/mydomain.com/privkey.pem
tls_random_source = dev:/dev/urandom
smtpd_client_new_tls_session_rate_limit = 10
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_tls_exclude_ciphers =
    EXP
    EDH-RSA-DES-CBC-SHA
    ADH-DES-CBC-SHA
    DES-CBC-SHA
    SEED-SHA
smtpd_tls_dh512_param_file = ${config_directory}/certs/dh_512.pem
smtpd_tls_dh1024_param_file = ${config_directory}/certs/dh_1024.pem
disable_vrfy_command = yes
smtpd_helo_required = yes
smtpd_delay_reject = yes

在 Postfix 中master.cf,除其他设置外,我还有:

smtp      inet  n       -       -       -       -       smtpd
  -o smtpd_enforce_tls=yes
  -o smtpd_use_tls=yes
  -o smtpd_tls_security_level=encrypt

submission inet n       -       -       -       -       smtpd
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o broken_sasl_auth_clients=yes

在 Dovecot 中10-ssl.conf,除其他设置外,我有:

ssl = required
ssl_ca = </etc/letsencrypt/live/mydomain.com/chain.pem
ssl_cert = </etc/letsencrypt/live/mydomain.com/fullchain.pem
ssl_key = </etc/letsencrypt/live/mydomain.com/privkey.pem

Gmail 是否因为不信任 LetsEncrypt 证书而错误地标记了它们,或者我的电子邮件确实是未加密发送的?

答案1

我通过将以下两行添加到 Postfix 来解决这个问题main.cf

smtp_tls_security_level = may
smtpd_tls_security_level = may

(我之所以设定,只是smtpd_tls_security_level因为一篇误导性的文章说,所有smtp_价值都贬值了smtpd_。)

答案2

您的电子邮件未加密发送。如果您只想尽力而为,请将以下内容添加到您的 main.cf 中

smtp_tls_security_level = may

要对发送到 Google 的电子邮件强制实施 TLS 加密,请将其添加到您的 main.cf

# Force TLS for outgoing server connection
smtp_tls_policy_maps = hash:/etc/postfix/tls_policy
smtp_tls_CApath = /etc/postfix/rootcas/ 

将 /etc/postfix/rootcas/ 替换为您信任的 Root CA 的位置,并在文件 /etc/postfix/tls_policy 中添加

#/C=US/O=Equifax/OU=Equifax Secure Certificate Authority
gmail.com       secure ciphers=high
google.com      secure ciphers=high
googlemail.com  secure ciphers=high

这将强制发送到 gmail.com.、google.com 和 googlemail.com 的电子邮件以加密方式发送,并对 SMTP 服务器进行身份验证

如果你不想进行身份验证而只想加密(这对于伪造证书的网站来说是必要的),请使用

gmail.com       encrypt ciphers=high
google.com      encrypt ciphers=high
googlemail.com  encrypt ciphers=high

重新启动 postfix 之前执行

postmap /etc/postfix/tls_policy

答案3

考虑与 SMTP 有关的客户端/服务器关系,并且设置有意义:

2.1. 基本结构

SMTP 设计可以描述为:

              +----------+                +----------+
  +------+    |          |                |          |
  | User |<-->|          |      SMTP      |          |
  +------+    |  Client- |Commands/Replies| Server-  |
  +------+    |   SMTP   |<-------------->|    SMTP  |    +------+
  | File |<-->|          |    and Mail    |          |<-->| File |
  |System|    |          |                |          |    |System|
  +------+    +----------+                +----------+    +------+
               SMTP client                SMTP server

(来源:rfc5321.txt)

因此:

“smtp_tls_security_level” 适用于 Postfix SMTP 客户端。请参阅:http://www.postfix.org/postconf.5.html#smtp_tls_security_level

“SMTPd_tls_security_level”用于 Postfix SMTP 服务器,请参阅:http://www.postfix.org/postconf.5.html#smtpd_tls_security_level

当 postfix 向 gmail 传输邮件时,smtp_tls_security_level设置是相关设置。

当 postfix 是接收通过 smtp 发送邮件,简体中文:d_tls_security_level设置相关。

相关内容