Roundcube&Postfix SMTP:SSL例程:SSL3_READ_BYTES:tlsv1警报未知ca:s3_pkt.c

我有一个我个人使用的Postfix / Dovecot / Roundcube设置,以及提供给其他用户。 我正试图将这整个设置转移到一个新的框,但有一些问题。

邮件接收工作正常,(只在内部进行testing,域名尚未传输),以及使用TLS / SSL(例如Thunderbird)的外部IMAP和SMTP,

问题是,我的圆形立方体,它可以使用IMAP到127.0.0.1,并显示用户的电子邮件奇妙,但不能发送电子邮件,只是声称: "SMTP Error (220): Authentication failed."

奇怪的是,在我的当前服务器上使用相同的Postfix / Dovecotconfiguration,Roundcube不能再在我的新服务器上访问它。 以下是相关的roundcubeconfiguration:

 $config['smtp_server'] = 'tls://localhost'; // Log SMTP conversation to <log_dir>/smtp or to syslog $config['smtp_debug'] = true; // SMTP port (default is 25; use 587 for STARTTLS or 465 for the // deprecated SSL over SMTP (aka SMTPS)) $config['smtp_port'] = 587; // SMTP username (if required) if you use %u as the username Roundcube // will use the current username for login $config['smtp_user'] = '%u'; // SMTP password (if required) if you use %p as the password Roundcube // will use the current user's password for login $config['smtp_pass'] = '%p'; 

Roundcube的日志/错误日志简单地说:

 [02-Jan-2015 16:55:49 America/New_York] STARTTLS failed (): [02-Jan-2015 16:55:49 -0500]: SMTP Error: SMTP error: Authentication failure: STARTTLS failed (Code: ) in /var/wwwmail/program/lib/Roundcube/rcube.php on line 1505 (POST /?_task=mail&_unlock=loading1420235752730&_lang=undefined&_framed=1?_task=mail&_action=send) 

Roundcube的日志/ smtp日志显示:

 [02-Jan-2015 17:50:01 -0500]: Recv: 220 example.net ESMTP Postfix [02-Jan-2015 17:50:01 -0500]: Send: EHLO example.net [02-Jan-2015 17:50:01 -0500]: Recv: 250-example.net [02-Jan-2015 17:50:01 -0500]: Recv: 250-PIPELINING [02-Jan-2015 17:50:01 -0500]: Recv: 250-SIZE 104857600 [02-Jan-2015 17:50:01 -0500]: Recv: 250-VRFY [02-Jan-2015 17:50:01 -0500]: Recv: 250-ETRN [02-Jan-2015 17:50:01 -0500]: Recv: 250-STARTTLS [02-Jan-2015 17:50:01 -0500]: Recv: 250-ENHANCEDSTATUSCODES [02-Jan-2015 17:50:01 -0500]: Recv: 250-8BITMIME [02-Jan-2015 17:50:01 -0500]: Recv: 250 DSN [02-Jan-2015 17:50:01 -0500]: Send: STARTTLS [02-Jan-2015 17:50:01 -0500]: Recv: 220 2.0.0 Ready to start TLS [02-Jan-2015 17:50:01 -0500]: Send: RSET [02-Jan-2015 17:50:01 -0500]: Recv: MIA…"qhçR¸ [02-Jan-2015 17:50:01 -0500]: Send: QUIT 

这里是我的postfixconfiguration/etc/postfix/main.cf的相关片段

 # TLS parameters for SMTP service smtpd_tls_security_level = may smtpd_tls_cert_file = /etc/ssl/private/example.net/example.net.crt smtpd_tls_key_file = /etc/ssl/private/example.net/example.net.key smtpd_tls_auth_only = yes 

以下是/etc/postfix/master.cf中我的postfixconfiguration的相关片段

 smtp inet n - - - - smtpd -o content_filter=spamassassin submission inet n - n - - smtpd -o syslog_name=postfix/submission -o smtpd_tls_security_level=encrypt -o smtpd_sasl_auth_enable=yes -o cleanup_service_name=cleanup_submit smtps inet n - - - - smtpd -o content_filter=spamassassin -o syslog_name=postfix/smtps -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject -o milter_macro_daemon_name=ORIGINATING 

Postfix日志/var/log/mail.log报告以下错误:

 Jan 2 17:50:01 example postfix/submission/smtpd[19959]: connect from localhost.localdomain[127.0.0.1] Jan 2 17:50:01 example postfix/submission/smtpd[19959]: SSL_accept error from localhost.localdomain[127.0.0.1]: 0 Jan 2 17:50:01 example postfix/submission/smtpd[19959]: warning: TLS library problem: error:14094418:SSL routines:SSL3_READ_BYTES:tlsv1 alert unknown ca:s3_pkt.c:1292:SSL alert number 48: Jan 2 17:50:01 example postfix/submission/smtpd[19959]: lost connection after STARTTLS from localhost.localdomain[127.0.0.1] Jan 2 17:50:01 example postfix/submission/smtpd[19959]: disconnect from localhost.localdomain[127.0.0.1] 

我已经阅读了一些类似的错误代码的其他问题,但他们似乎都使用自签名证书,或者添加一个链接到/ etc / ssl / certs / ,我已经尝试,虽然我可能会错过理解,并链接错误的证书。

Roundcube更新到1.0.4,本来应该解决由于opensslPHP版本不兼容问题。 我什么都没有想法,任何人有任何想法?

上面的错误消息看起来像一个客户端(由roundcube调用的PHP脚本) 未能validation对等证书,因为未知的CA。 这个错误发生的原因有很多。

关于openssl,Roundcube版本1.0-RC及更高版本附带SSL连接选项。 在版本1.0-RC和1.0.3中分别添加了参数smtp_conn_optionsimap_conn_options 。 默认情况下,两个参数的值都是null。 下面的代码片段取自roundcube文件config/defaults.inc.php 。 你可以参考PHP手册来获得这个参数的完整描述。

 // SMTP socket context options // See http://php.net/manual/en/context.ssl.php // The example below enables server certificate validation, and // requires 'smtp_timeout' to be non zero. // $config['smtp_conn_options'] = array( // 'ssl' => array( // 'verify_peer' => true, // 'verify_depth' => 3, // 'cafile' => '/etc/openssl/certs/ca.crt', // ), // ); $config['smtp_conn_options'] = null; 

在许多使用自签名证书的系统中,默认值适用于PHP 5.5及更早版本。 默认情况下, PHP 5.6将validation安装的CA的对等证书并validation对等名称 。

现在,看起来像Debian jessie也提供了默认的PHP版本5.6 。 显然PHP无法validation后缀证书。 可能的原因是,PHP在verify_peer_name中失败(因为您在主机名中指定了localhost)或在verify_peer中(因为CA是未知的)


Arch Linux用户也遇到类似的情况。 解决scheme是:

  • 在openssl cert目录中安装CA证书
  • 在roundcube smtp_server选项中,将localhost更改为Postfix FQDN(来自OP的解决scheme)
  • 在smtp_conn_options中禁用verify_peer和/或verify_peer_name

PHP 5.6做SSL对等validation,这意味着它检查SMTP服务器的证书是否是已知的CA.

smtp_server选项必须与证书的CN字段匹配! (通用名称)

所以不要把localhost放在那里,把完全合格的域名放在那里,与你的证书相匹配。

致谢: https : //www.blogobramje.nl/posts/Roundcube_sending_mail_broken_with_PHP_5.6_-_STARTTLS_failed/

因为我使用dovecot,我的解决scheme是将ca添加到/etc/dovecot/dovecot.conf

 ssl_ca = </etc/ssl/ca.pem 

我有同样的错误。 修复它在postfix main.cf文件中添加CA文件。 位置可能位于/etc/postfix/main.cf

smtpd_tls_CAfile = /etc/postfix/cacert.pem
smtpd_tls_cert_file = /etc/postfix/foo-cert.pem
smtpd_tls_key_file = /etc/postfix/foo-key.pem

同样的问题! 快速变通解决方法:在config / defaults.inc.php中将verify_peer更改为false。

 $config['smtp_conn_options'] = array( 'ssl' => array( 'verify_peer' => false, 'verify_depth' => 3, 'cafile' => '/etc/openssl/certs/ca.crt', ), ); 

警告只适用于testing; 不适用于生产环境