我正在转换现有的邮件服务器以支持客户的加密 SMTP,但我遇到了这个难题,几乎没有有用的日志数据来帮助我转发。使用常规未加密的 SMTP 时一切都正常;只有在尝试使用加密 SMTP 时,事情才会变得糟糕。
我的 exim 配置文件包含以下内容:
# Allow any client to use TLS
tls_advertise_hosts = *
# Specify the location of the Exim server's TLS certificate and private key.
tls_certificate = /etc/exim/exim.crt
tls_privatekey = /etc/exim/exim.key
最初,进出口银行出现为确保正常运行,我可以安全地连接到邮件服务器并验证自己的身份,但就在我进入 SMTP 会话中的收件人部分后,连接断开。使用未加密的连接时不会发生此问题。
为了测试安全 SMTP,我使用以下命令:
openssl s_client -starttls smtp -crlf -connect localhost:25
这是我得到的输出:
CONNECTED(00000003)
depth=0 C = ZA, etc, etc
verify error:num=18:self signed certificate
verify return:1
depth=0 C = ZA, etc, etc
verify return:1
---
Certificate chain
0 s:/C=ZA/etc,etc
i:/C=ZA/etc,etc
---
Server certificate
-----BEGIN CERTIFICATE-----
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXX==
-----END CERTIFICATE-----
subject=/C=ZA/etc,etc
---
No client certificate CA names sent
---
SSL handshake has read 1275 bytes and written 444 bytes
---
New, TLSv1/SSLv3, Cipher is AES256-SHA
Server public key is 1024 bit
Secure Renegotiation IS supported
Compression: zlib compression
Expansion: zlib compression
SSL-Session:
Protocol : TLSv1
Cipher : AES256-SHA
Session-ID: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Session-ID-ctx:
Master-Key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Key-Arg : None
PSK identity: None
PSK identity hint: None
TLS session ticket:
0000 - d0 cd ff b6 0c a2 fb 6c-f6 69 dc 0b a7 aa f3 1a .......l.i......
0010 - 10 76 75 05 15 d8 8c 21-cb eb b8 ae ec 34 7d b3 .vu....!.....4}.
0020 - 7a bf f0 d6 7d df 26 27-41 1e d1 2a 35 bf 2f 0c z...}.&'A..*5./.
0030 - 25 6a 32 15 6e 53 d2 30-31 1b d9 60 e6 11 20 73 %j2.nS.01..`.. s
0040 - 57 e3 76 96 e7 7e dc da-98 f2 cc a7 e5 58 62 b2 W.v..~.......Xb.
0050 - ec db 58 91 16 14 18 ff-15 64 d6 66 1f 75 92 96 ..X......d.f.u..
0060 - 65 43 f8 2c 4a 42 81 41-0c 2f 46 84 38 0c c5 e0 eC.,JB.A./F.8...
0070 - 8d 7b d7 7e 12 0e 28 ca-f0 f9 b5 d0 b2 a6 ab 66 .{.~..(........f
0080 - f8 c5 33 e3 cb 16 f5 76-8f e7 49 0c 49 69 31 43 ..3....v..I.Ii1C
0090 - 05 25 dc 75 3a 07 13 91-63 ff 13 fd b0 2c 9f 8b .%.u:...c....,..
Compression: 1 (zlib compression)
Start Time: 1315250595
Timeout : 300 (sec)
Verify return code: 18 (self signed certificate)
---
250 HELP
HELO localhost
250 OK
MAIL FROM:[email protected]
250 OK
RCPT TO:[email protected]
RENEGOTIATING
depth=0 C = ZA, etc, etc
verify error:num=18:self signed certificate
verify return:1
depth=0 C = ZA, etc, etc
verify return:1
421 lost input connection
read:errno=0
我已经用垃圾数据替换了上述输出中的电子邮件地址和组织树,因为这无关紧要,因为我使用常规 SMTP 时不会遇到同样的问题。无论我尝试从本地主机还是从外部源进行连接,上述事务都会发生。我还应该注意,我使用的是使用 OpenSSL 生成的自签名证书。此外,在上面的例子中没有身份验证数据,因为我是从本地主机执行测试的,这允许所有邮件而无需身份验证。
正如您在上面的输出中看到的,Exim 似乎在发出字符串“RENEGOTIATING”期间/之后中断。
由于我在 SMTP 会话期间收到的输出没有太大帮助,我还尝试在调试 +all 模式下运行 Exim。为了简洁起见,我不会发布完整的 SMTP 事务,因为整个会话都很正常,直到我指定收件人地址为止。这是我输入收件人地址并按下回车键后获得的 Exim 调试数据的确切片段:
21:42:10 7425 SSL info: before accept initialization
21:42:10 7425 SSL info: before accept initialization
21:42:10 7425 SSL info: SSLv3 read client hello A
21:42:10 7425 SSL info: SSLv3 write server hello A
21:42:10 7425 SSL info: SSLv3 write certificate A
21:42:10 7425 SSL info: SSLv3 write server done A
21:42:10 7425 SSL info: SSLv3 flush data
21:42:10 7425 SSL info: SSLv3 read client key exchange A
21:42:10 7425 SSL info: SSLv3 read finished A
21:42:10 7425 SSL info: SSLv3 write session ticket A
21:42:10 7425 SSL info: SSLv3 write change cipher spec A
21:42:10 7425 SSL info: SSLv3 write finished A
21:42:10 7425 SSL info: SSLv3 flush data
21:42:10 7425 SSL info: SSL negotiation finished successfully
21:42:10 7425 SSL info: SSL negotiation finished successfully
21:42:10 7425 Got SSL error 2
21:42:10 7425 SMTP>> 421 lost input connection
21:42:10 7425 tls_do_write(1db4020, 48)
21:42:10 7425 SSL_write(SSL, 1db4020, 48)
21:42:10 7425 outbytes=48 error=0
21:42:10 7425 LOG: lost_incoming_connection MAIN
21:42:10 7425 unexpected disconnection while reading SMTP command from (localhost) [127.0.0.1]
21:42:10 7425 search_tidyup called
21:42:10 7194 child 7425 ended: status=0x100
21:42:10 7194 0 SMTP accept processes now running
21:42:10 7194 Listening...
答案1
我通过谷歌搜索花了 30 秒找到了这个“openssl s_client 正在重新协商”: s_client 的 R“功能”
总结一下 - 在 s_client 会话中按“R”会导致 openssl 重新协商。请尝试输入“rcpt to:”而不是“RCPT TO”。
您还可以尝试更适合 SMTP 特定测试的工具,例如Tony Finch 的 smtpc或者斯瓦克斯。
答案2
为了要求exim
我在身份验证时进行加密设置/etc/exim/exim.conf
:
auth_advertise_hosts = ${if eq{$tls_cipher}{}{}{*}}
我也强制tls 1.2
:
openssl_options = +no_sslv2 +no_sslv3 +no_tlsv1 +no_tlsv1_1
在两台相同的exim
服务器之间,我注意到一台使用AES-GCM
,另一台使用ChaCha20-Poly1305
加密,但不知道为什么。使用的加密方案取决于是否host
具有AES
硬件加速在`cpu中。