我想启用端口25上的STARTTLS,但由于未知的原因,它只能在端口465上工作。
master.cf:
smtp inet n - - - - smtpd -o syslog_name=postfix/smtp -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=no -o smtpd_client_restrictions=permit_sasl_authenticated,reject -o milter_macro_daemon_name=ORIGINATING #smtp inet n - - - 1 postscreen #smtpd pass - - - - - smtpd #dnsblog unix - - - - 0 dnsblog #tlsproxy unix - - - - 0 tlsproxy #submission inet n - - - - smtpd # -o syslog_name=postfix/submission # -o smtpd_tls_security_level=encrypt # -o smtpd_sasl_auth_enable=yes # -o smtpd_client_restrictions=permit_sasl_authenticated,reject # -o milter_macro_daemon_name=ORIGINATING #smtps inet n - - - - smtpd # -o syslog_name=postfix/smtps # -o smtpd_tls_wrappermode=yes # -o smtpd_sasl_auth_enable=no # -o smtpd_client_restrictions=permit_sasl_authenticated,reject # -o milter_macro_daemon_name=ORIGINATING
main.cf:
smtp_tls_loglevel = 1 smtp_tls_note_starttls_offer = yes smtp_tls_security_level = may smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache smtp_use_tls = yes smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU) smtpd_client_restrictions = permit_mynetworks, reject_unknown_client smtpd_helo_required = yes smtpd_helo_restrictions = permit_mynetworks, reject_invalid_hostname, reject_non_fqdn_hostname smtpd_recipient_limit = 25 smtpd_tls_CAfile = /root/chain.pem smtpd_tls_auth_only = no smtpd_tls_cert_file = /root/cert.pem smtpd_tls_key_file = /root/key.pem smtpd_tls_loglevel = 1 smtpd_tls_received_header = yes smtpd_tls_security_level = may smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtpd_tls_session_cache_timeout = 3600s smtpd_use_tls = yes tls_random_prng_update_period = 3600s tls_random_source = dev:/dev/urandom
现在当我尝试用openssl s_client -connect hostname:25检查证书时,我得到这个错误:
CONNECTED(00000003) write:errno=104 no peer certificate available No client certificate CA names sent SSL handshake has read 0 bytes and written 308 bytes
在端口465一切正常,所以证书和CA链是正确的。
日志说:
postfix/smtp/smtpd[2623]: SSL_accept error postfix/smtp/smtpd[2623]: warning: TLS library problem: 2623:error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol:s23_srvr.c:649:
帮助非常感谢!
SMTPS意味着通过TLS实现SMTP,就像使用HTTPS一样。 所以首先build立一个TLS连接(没有回退),然后启动STMP。 就像没有人希望HTTP-Port 80上使用HTTPS一样,你不应该指望连接到你的STMP服务的人发送TLS请求。 因此, 如果您执行TLS,则端口25上到您服务器的所有连接都可能失败。
STARTTLS使encryption可选。 首先,build立一个正常的,未encryption的SMTP连接,然后服务器宣布它可以升级到STARTTLS(使用所谓的STMP扩展)。 如果服务器也支持STARTTLS(并且启用了使用),则客户端请求升级到TLS。
SMTPS(SMTP over TLS)是通过smtpd_tls_wrappermode=yes在Postfix中启用的,您将其设置为smtp服务,因此在端口25上。如上所述, 不build议这样做。
我想在这个问题上引用部分Bettercrypto的文章Applied Crypto Hardening for master.cf和main.cf 您也可以参考它,因为您的main.cf中可能有一些设置阻碍了TLS使用的正确设置。
main.cf :
# enable opportunistic TLS support in the SMTP server and client smtpd_tls_security_level = may smtp_tls_security_level = may # if you have authentication enabled, only offer it after STARTTLS smtpd_tls_auth_only = yes
master.cf :
smtp inet n - - - - smtpd submission inet n - - - - smtpd -o smtpd_tls_security_level=encrypt
我们没有为端口25上的TLS设置任何新function,因为main.cf中的默认值是我们所需要的。