Ssl

郵件客戶端連接到 postfix 時出現 SSL_accept 錯誤

  • December 6, 2020

我已經設法在我的伺服器上設置postfixdovecot使用自簽名證書。我可以在那裡使用 telnet 命令發送和接收電子郵件。現在我想從筆記型電腦上的 Thunderbird 客戶端連接到我的郵件伺服器,但它失敗了,下面是輸出/var/log/mail.log

postfix/submission/smtpd[11560]: connect from unknown[95.134.50.75]
postfix/submission/smtpd[11439]: SSL_accept error from unknown[95.134.50.75]: lost connection
postfix/submission/smtpd[11439]: lost connection after CONNECT from unknown[95.134.50.75]

這是/etc/postfix/master.cf我在設置中更改的部分內容:

# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
smtp      inet  n       -       -       -       -       smtpd
smtps     inet  n       -       -       -       -       smtpd
#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_wrappermode=yes
 -o smtpd_tls_security_level=encrypt
 -o smtpd_sasl_auth_enable=yes
 -o smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject
 -o milter_macro_daemon_name=ORIGINATING
 -o smtpd_sasl_type=dovecot
 -o smtpd_sasl_path=private/auth

這是我的/etc/postfix/main.cf

myhostname = mail.myserver.com
myorigin = /etc/mailname
mydestination = mail.myserver.com, myserver.com, localhost, localhost.localdomain
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

smtpd_tls_cert_file=/etc/ssl/certs/mailcert.pem
smtpd_tls_key_file=/etc/ssl/private/mail.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_tls_protocols = !SSLv2, !SSLv3

smtpd_tls_security_level = may
smtp_tls_security_level = may
smtp_tls_loglevel = 1
smtpd_tls_loglevel = 1

local_recipient_maps = proxy:unix:passwd.byname $alias_maps

inet_protocols = all

另外,不確定這是否有幫助,但兩者都可以在伺服器telnet localhost 25telnet localhost 465工作,但只能telnet myserver.com 465在我的筆記型電腦上工作,當我嘗試埠 25 時,它會說telnet: Unable to connect to remote host: Connection timed outufw在伺服器上處於非活動狀態。

我應該怎麼做才能修復它?

埠 465 用於 SMTPS,它在建立連接時立即使用 SSL,然後在建立安全連接後使用與通常在埠 25 上找到的相同的 SMTP 協議。您可以使用以下命令從命令行進行測試:

openssl s_client -connect smtp.example.com:465

使用 telnet 連接到埠 465 將導致日誌文件中出現錯誤消息,因為未使用 SSL 協議。

僅出於完整性考慮:在普通 SMTP 埠 TCP/25 上測試 TLS

openssl s_client -starttls smtp -connect  smtp.example.com:25

引用自:https://serverfault.com/questions/644085