Postfix SMTP客户端没有使用tls_append_default_CA对系统范围的CA证书进行validation

在运行Debian Wheezy的面向Internet的Postfix SMTP服务器上,我想与一些已知的服务器build立安全连接。 有些是我自己的,运行我自己的PKI / CA,有些是公共SMTP服务器,如Google的Gmail服务器。 为了检查我正在运行的服务器上的证书,我已经指定了

smtp_tls_CAfile = /usr/local/share/ca-certificates/Gert_van_Dijk_Root_CA_2014.crt 

并确保公共服务器也可以通过内置的系统证书库进行validation,我明确指定了

 tls_append_default_CA = yes 

为了确保Postfix正确validation证书,我已经将全局TLS安全级别设置为“安全”。 在完成debugging此处所述的问题后,我会将其更改回“可能”,以便在某些域中secure smtp_tls_policy_maps

 smtp_tls_security_level = secure 

它validation我自己的服务器就好! 这些都使用由Gert_van_Dijk_Root_CA_2014.crt签名的证书运行。 但是,当SMTP客户端尝试向Google的SMTP服务器发送邮件时,它实际上并没有通过tls_append_default_CA设置追加证书。 我期望它在Debian上附加来自/etc/ssl/certs文件。

 postfix/smtp[32271]: effective TLS level: secure [...] postfix/smtp[32271]: < alt1.gmail-smtp-in.l.google.com[64.233.164.26]:25: 220 2.0.0 Ready to start TLS [...] postfix/smtp[32271]: DE6D0403EB: Server certificate not verified 

以下是我所尝试的:

  • master.cf为smtp客户端禁用chroot,如下所示:

     smtp unix - - n - - smtp 

    没有帮助。

  • 添加详细的日志logging。 我已经添加了-v到上面的行。 必须禁用rsyslog速率限制,但这并没有改善任何东西。 它提到的有关TLSvalidation的DE6D0403EB: Server certificate not verifiedDE6D0403EB: Server certificate not verified行。

  • 尝试对stream程进行调整,以查看访问CA证书是否存在问题。 它似乎SMTP客户端被产生为每个交付尝试的新过程。 这使通用strace -p <PID>不可能。

  • search类似的问题。 我似乎只是发现这个非常类似的问题 ,但这是关于指定smtp_tls_CAfile设置,我这样做。 如果设置了smtp_tls_CAfile ,则应该附加系统范围的CA证书。

  • 全部恢复到Debian的默认值,除了smtp_tls_security_level = secure 。 在向Google发送同样的错误时也失败了。 Debian的Postfix的错误呢?

  • 同上,然后禁用SMTP客户端的chroot,然后明确设置smtp_tls_CApath = /etc/ssl/certs 。 证书validation仍然失败。

  • 添加TLSdebugging级别。 显示:

     postfix/tlsmgr[17486]: write smtp TLS cache entry smtp:64.233.164.26:25:mx.google.com&p=1&c=aNULL:-aNULL:ALL:!EXPORT:!LOW:+RC4:@STRENGTH:!aNULL&l=268439647: time=1421622891 [data 1975 bytes] postfix/smtp[17485]: alt1.gmail-smtp-in.l.google.com[64.233.164.26]:25: subject_CN=mx.google.com, issuer_CN=Google Internet Authority G2, fingerprint 88:C0:85:C8:CB:96:29:8F:4E:15:11:80:C5:9A:89:0D, pkey_fingerprint=E0:32:29:21:69:38:EA:F9:B6:0C:F6:BD:86:12:16:B9 postfix/smtp[17485]: Untrusted TLS connection established to alt1.gmail-smtp-in.l.google.com[64.233.164.26]:25: TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits) postfix/smtp[17485]: DE6D0403EB: Server certificate not trusted 
  • 在同一个系统上的OpenSSL手动validation显示一切都应该没问题。

     $ openssl s_client -connect 64.233.164.26:25 -starttls smtp CONNECTED(00000003) depth=2 C = US, O = GeoTrust Inc., CN = GeoTrust Global CA verify error:num=20:unable to get local issuer certificate verify return:0 
  • 同时也为tlsmgr禁用chroot我终于得到了一个Trusted TLS connection established ,但后来仍然认为连接是不安全的( Server certificate not verified ):

     postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: certificate verification depth=3 verify=1 subject=/C=US/O=Equifax/OU=Equifax Secure Certificate Authority postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: certificate verification depth=2 verify=1 subject=/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: certificate verification depth=1 verify=1 subject=/C=US/O=Google Inc/CN=Google Internet Authority G2 postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: certificate verification depth=0 verify=1 subject=/C=US/ST=California/L=Mountain View/O=Google Inc/CN=mx.google.com postfix/smtp[27198]: SSL_connect:SSLv3 read server certificate A postfix/smtp[27198]: SSL_connect:SSLv3 read server key exchange A postfix/smtp[27198]: SSL_connect:SSLv3 read server done A postfix/smtp[27198]: SSL_connect:SSLv3 write client key exchange A postfix/smtp[27198]: SSL_connect:SSLv3 write change cipher spec A postfix/smtp[27198]: SSL_connect:SSLv3 write finished A postfix/smtp[27198]: SSL_connect:SSLv3 flush data postfix/smtp[27198]: SSL_connect:SSLv3 read server session ticket A postfix/smtp[27198]: SSL_connect:SSLv3 read finished A postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: subjectAltName: aspmx.l.google.com postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: subjectAltName: alt1.aspmx.l.google.com postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: subjectAltName: alt2.aspmx.l.google.com postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: subjectAltName: alt3.aspmx.l.google.com postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: subjectAltName: alt4.aspmx.l.google.com postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: subjectAltName: gmail-smtp-in.l.google.com postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: subjectAltName: alt1.gmail-smtp-in.l.google.com postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: subjectAltName: alt2.gmail-smtp-in.l.google.com postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: subjectAltName: alt3.gmail-smtp-in.l.google.com postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: subjectAltName: alt4.gmail-smtp-in.l.google.com postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: subjectAltName: gmr-smtp-in.l.google.com postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: subjectAltName: alt1.gmr-smtp-in.l.google.com postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: subjectAltName: alt2.gmr-smtp-in.l.google.com postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: subjectAltName: alt3.gmr-smtp-in.l.google.com postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: subjectAltName: alt4.gmr-smtp-in.l.google.com postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: subjectAltName: mx.google.com postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: subjectAltName: aspmx2.googlemail.com postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: subjectAltName: aspmx3.googlemail.com postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: subjectAltName: aspmx4.googlemail.com postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: subjectAltName: aspmx5.googlemail.com postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25 CommonName mx.google.com postfix/smtp[27198]: gmail-smtp-in.l.google.com[173.194.67.26]:25: subject_CN=aspmx.l.google.com, issuer_CN=Google Internet Authority G2, fingerprint 88:C0:85:C8:CB:96:29:8F:4E:15:11:80:C5:9A:89:0D, pkey_fingerprint=E0:32:29:21:69:38:EA:F9:B6:0C:F6:BD:86:12:16:B9 postfix/smtp[27198]: Trusted TLS connection established to gmail-smtp-in.l.google.com[173.194.67.26]:25: TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits) postfix/smtp[27198]: DE6D0403EB: Server certificate not verified 

有没有办法在后台运行在前台debuggingSMTP 客户端 ? 所有的debugging东西似乎是关于smtpd进程。 🙁

相关的进一步configuration:

 # postconf -n | grep -E "^(smtp_|tls_)" smtp_tls_CAfile = /usr/local/share/ca-certificates/Gert_van_Dijk_Root_CA_2014.crt smtp_tls_security_level = secure smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache tls_append_default_CA = yes # /etc/postfix/master.cf: tlsmgr unix - - n 1000? 1 tlsmgr smtp unix - - n - - smtp -v 

使用smtp_tls_security_level = secure和默认值smtp_tls_secure_cert_match (smtp_tls_secure_cert_match = nexthop,dot-nexthop)后缀将不会信任来自MXlogging的结果。 换句话说,postfix将使用从内部表(如传输表)获得的下一跳。

这就是为什么后缀仍然说明服务器证书没有validation 。 Postfix文档明确指出

已validation (对等证书由受信任的CA签名并经过validation的对等名称;或者:具有期望的公钥或证书指纹的对等证书)

Postfix SMTP客户端 :远程SMTP服务器的证书由Postfix SMTP客户端信任的CA签名,证书名称与目标或服务器名称相匹配。 Postfix SMTP客户端被configuration为需要validation名称,否则validation状态将只是“可信”。

您可以减lesssmtp_tls_security_levelverified以便postfix将信任MXlogging的结果,并用它来validation过程。 在postfix文档中描述了另一种方法。

  • 没有传输的安全通道TLS(5)表覆盖

    Postfix将使用smtp_tls_policy_maps来执行validation过程。

  • 带有传输(5)表的安全通道TLS覆盖:

    在这种情况下,到example.com及其相关域的stream量将被发送到单个逻辑网关(为了避免单点故障,其名称可能会parsing为一个或多个负载均衡器地址或多个物理主机的组合地址)。 所有可通过网关的IP地址访问的物理主机都在其证书中列出逻辑网关名称。