大网数据广告活动
服务器运维问答

What are the correct settings to enable TLS between Postfix and Dovecot via LMTP?

· 52CE 我爱测

I am trying to get Postfix to forward mail via LMTP to Dovecot. This works fine when TLS is turned off in the settings on both sides. Once TLS settings are enabled, Postfix connects via LMTP and Dovecot sees the connection, but b…

问题原文

原帖链接 · Nick · CC BY-SA 4.0

I am trying to get Postfix to forward mail via LMTP to Dovecot. This works fine when TLS is turned off in the settings on both sides.

Once TLS settings are enabled, Postfix connects via LMTP and Dovecot sees the connection, but both servers seem to get stuck there with no further information in the logs (logs below).

What are the correct TLS settings to make this work?

These are the relevant parts of the configuration files for both servers as currently set:

/etc/dovecot/dovecot.conf:

protocols = imap lmtp

# Enable SSL (global) for IMAP connections
ssl = required
ssl_cert = </etc/ssl/imap.domain.com/imap.domain.com.crt
ssl_key = </etc/ssl/imap.domain.com/imap.domain.com.key


protocol lmtp {
    ssl_cert = </etc/ssl/imap.domain.com/imap.domain.com.crt
    ssl_key = </etc/ssl/imap.domain.com/imap.domain.com.key
    ssl_ca = </etc/ssl/imap.domain.com/authority.crt
    ssl_verify_client_cert = yes
    auth_ssl_require_client_cert = yes
    ssl=required
}


service lmtp {
  user = vmail
  inet_listener lmtp {
    address = * ::
    port = 24
    ssl=yes
  }
}

/etc/postfix/main.cf:

lmtp_use_tls = yes
lmtp_tls_security_level=encrypt
lmtp_tls_loglevel = 2
lmtp_tls_session_cache_database = btree:${data_directory}/lmtp_cache    
lmtp_tls_CApath = /etc/ssl/certs
lmtp_tls_CAfile=/etc/ssl/domain.com/authority.crt
lmtp_tls_cert_file=/etc/ssl/domain.com/domain.com.client.crt
lmtp_tls_key_file=/etc/ssl/domain.com/domain.com.key    
lmtp_tls_note_starttls_offer = yes

Dovecot server's mail log:

lmtp(1939): Info: Connect from xx.xx.xx.xx
lmtp(2500): Debug: SSL: where=0x10, ret=1: before SSL initialization
lmtp(2500): Debug: SSL: where=0x2001, ret=1: before SSL initialization
lmtp(2500): Debug: SSL: where=0x2002, ret=-1: before SSL initialization
lmtp(2500): Debug: SSL: where=0x2002, ret=-1: before SSL initialization
lmtp(2500): Debug: SSL: where=0x2002, ret=-1: before SSL initialization
lmtp(1944): Info: Disconnect from xx.xx.xx.xx: Disconnected for inactivity (state=GREETING)

The Postfix Server's mail log:

Nov  1 22:35:18 servername postfix/lmtp[65067]: initializing the client-side TLS engine
Nov  1 22:35:18 servername postfix/lmtp[65050]: 9935F2317D: to=<[email omitted]>, relay=remote.server.com[yy.yy.yy.yy]:24, delay=1220, delays=920/0.02/300/0, dsn=4.4.2, status=deferred (lost connection with remote.server.com[yy.yy.yy.yy] while receiving the initial server greeting)

Update

If I run:

openssl s_client -connect domain.com:24 -CAfile /etc/ssl/domain.com/authority.crt

on the Postfix machine, it connects via TLS to the Dovecot server via LMTP, and I can issue telnet commands to Dovecot. So it seems that Dovecot is accepting TLS connections, but when Postifx tries to connect, the negotiation stalls out.

If I run:

openssl s_client -starttls lmtp -connect domain.com:24 -CAfile /etc/ssl/domain.com/authority.crt

I just get:

CONNECTED(00000003)

and can't issue any telnet commands.

已采纳解答

原帖链接 · anx · CC BY-SA 4.0

If (according to your openssl s_client test) properly wrapping the entire LMTP session in TLS works, and its just the STARTTLS compatibility hack that is causing trouble.. tell Postfix to do the former.

lmtp_tls_wrappermode=yes

Do verify however, that your settings to require a client cert are effective.. your s_client test results do not seem to have established that part yet. Also, drop the lmtp_use_tls settings - it is overridden and obsoleted by lmtp_tls_security_level.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2023-11-01)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。