![dovecot 的 SSL 问题](https://linux22.com/image/608785/dovecot%20%E7%9A%84%20SSL%20%E9%97%AE%E9%A2%98.png)
我在通过 gmail 从外部 pop 邮箱检索邮件时遇到了一个似乎经常发生但尚未解决的问题。查看错误详细信息,它显示:
服务器响应:“验证失败”。
该邮件服务器是我自己的服务器,当我从终端连接时:
~$ telnet mail.mydomain.com:995
我得到以下信息:
Trying xx.xx.xxx.xx...
Connected to mail.mydomain.com.
Escape character is '^]'.
然后尝试登录时:
user myuser
Connection closed by foreign host.
在我的邮件日志中:
Mar 26 18:22:42 www dovecot: auth: Debug: Loading modules from directory: /usr/lib/dovecot/modules/auth
Mar 26 18:22:42 www dovecot: auth: Debug: Module loaded: /usr/lib/dovecot/modules/auth/libdriver_mysql.so
Mar 26 18:22:42 www dovecot: auth: Debug: auth client connected (pid=6554)
Mar 26 18:23:20 www dovecot: pop3-login: Disconnected (no auth attempts): rip=xx.xx.xxx.xx, lip=xx.xx.xxx.xx, TLS handshaking: SSL_accept() failed: error:140760FC:SSL
routines:SSL23_GET_CLIENT_HELLO:unknown protocol
使用以下方式测试 SSL 时:
~$ openssl s_client -connect mail.mydomain.com:995
我可以连接,但是使用这条线路(我购买了 godaddy 证书):
Verify return code: 19 (self signed certificate in certificate chain)
我可能做错了什么?以下是我的配置文件:
# 2.0.13: /etc/dovecot/dovecot.conf
# OS: Linux 3.0.0-13-server x86_64 Ubuntu 11.10 ext4
log_timestamp = "%Y-%m-%d %H:%M:%S "
mail_location = maildir:/home/vmail/%d/%n/Maildir
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date
namespace {
inbox = yes
location =
prefix = INBOX.
separator = .
type = private
}
passdb {
args = /etc/dovecot/dovecot-sql.conf
driver = sql
}
protocols = imap pop3
service auth {
unix_listener /var/spool/postfix/private/auth {
group = postfix
mode = 0660
user = postfix
}
unix_listener auth-userdb {
group = vmail
mode = 0600
user = vmail
}
unix_listener auth-master {
mode = 0600
user = vmail
}
user = root
}
ssl = required
ssl_cert = </etc/ssl/certs/mail.mydomain.com_combined.crt
ssl_key = </etc/ssl/private/mail.mydomain.key
userdb {
args = uid=5000 gid=5000 home=/home/vmail/%d/%n allow_all_users=yes
driver = static
}
protocol lda {
auth_socket_path = /var/run/dovecot/auth-master
log_path = /home/vmail/dovecot-deliver.log
mail_plugins = sieve
postmaster_address = [email protected]
}
protocol pop3 {
pop3_uidl_format = %08Xu%08Xv
}
disable_plaintext_auth = no
auth_verbose = yes
auth_debug = yes
后缀:
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = /usr/share/doc/postfix
# TLS parameters
smtpd_tls_cert_file = /etc/ssl/certs/mail.mydomain.com_combined.crt
smtpd_tls_key_file = /etc/ssl/private/mail.mydomain.com.key
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
myhostname = mail.mydomain.com
mydomain = mydomain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination =
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
html_directory = /usr/share/doc/postfix/html
message_size_limit = 30720000
virtual_alias_domains =
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, mysql:/etc/postfix/mysql-virtual_email2email.cf
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf
virtual_mailbox_base = /home/vmail
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_authenticated_header = yes
# see under Spam smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1
# Spam
disable_vrfy_command = yes
smtpd_delay_reject = yes
smtpd_helo_required = yes
smtpd_helo_restrictions = permit_mynetworks,
check_helo_access hash:/etc/postfix/helo_access,
reject_non_fqdn_hostname,
reject_invalid_hostname,
permit
smtpd_recipient_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_unauth_destination,
reject_invalid_hostname,
reject_non_fqdn_sender,
reject_non_fqdn_recipient,
reject_unknown_sender_domain,
reject_unknown_recipient_domain,
reject_non_fqdn_hostname,
reject_rbl_client sbl.spamhaus.org,
reject_rbl_client zen.spamhaus.org,
reject_rbl_client cbl.abuseat.org,
reject_rbl_client bl.spamcop.net,
permit
smtpd_error_sleep_time = 1s
smtpd_soft_error_limit = 10
smtpd_hard_error_limit = 20
答案1
没什么问题。您向我们展示的所有内容都与在端口 995 上运行的 POP/S(SSL 安全)服务器一致。您的openssl s_client
会话可能会出现问题,因为它的证书包中没有正确的 CA。
为什么谷歌无法从你的服务器获取电子邮件是一个合理的问题,但你发布的任何内容都无法解释这一故障。如果你能抓住谷歌从你的服务器检索邮件的行为,并发布那些dovecot 日志,那么我们就可以开始阐明这个问题。
编辑:Connection closed by foreign host
之所以发生这种情况,是因为,除非您本人能够流利地说 SSL 并能快速输入奇怪的字符,否则您无法使用 telnet 连接到 SSL 安全服务(NB:对于 TLS 安全服务来说,情况并非如此,但这不是 TLS 安全服务。您输入的“user myuser”不是有效的 SSL 握手,因此导致错误 SSL23_GET_CLIENT_HELLO:unknown protocol
。很抱歉,它“看起来不太好”,但一切都完全正确。
如果您尝试从openssl s_client
会话登录,您可能会更幸运;自签名证书警告对于会话来说只是信息性的,而不是致命的。
答案2
我认为这个帖子可能有点老了,但我会尽力做出贡献,其他人可能会发现它很有用。谷歌在连接邮件服务器时非常奇特,除非邮件服务器使用由公认机构颁发的真正的 SSL 证书(如“Starssl”等),否则谷歌甚至不会与您的服务器对话。
几个月前我遇到过类似的问题,当我最终使用非自签名证书时,我开始收到来自“雅虎、谷歌等”的电子邮件。因此,这肯定与自签名证书或未捆绑好的证书有关,如果您从公认的机构获得颁发的证书但仍然不起作用,请检查您是否已正确处理所有内容。注意最小的细节,任何事情都可能搞砸它。但第一个罪魁祸首是 CA。祝你好运,我希望这些信息可以帮助别人。