php – Roundcube&Postfix SMTP:SSL例程:SSL3_READ_BYTES:tlsv1 alert unknown ca:s3_pkt.c

前端之家收集整理的这篇文章主要介绍了php – Roundcube&Postfix SMTP:SSL例程:SSL3_READ_BYTES:tlsv1 alert unknown ca:s3_pkt.c前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有个人使用的Postfix / Dovecot / Roundcube设置,以及提供给其他用户.我试图将整个设置转移到一个新的盒子,但有一些问题.

邮件接收工作正常,(仅在内部测试,域尚未传输.)以及外部IMAP& SMTP使用TLS / SSL工作很棒(例如Thunderbird)

问题在于我的圆形立方体设置,它可以使用IMAP到127.0.0.1,并且显示用户的电子邮件,但无法发送电子邮件,只是声称:“SMTP错误(220):身份验证失败.”

奇怪的是,使用我在当前服务器上使用的相同Postfix / Dovecot配置,Roundcube无法再在我的新服务器上访问它.这是相关的roundcube配置:

  1. $config['smtp_server'] = 'tls://localhost';
  2.  
  3. // Log SMTP conversation to <log_dir>/smtp or to syslog
  4. $config['smtp_debug'] = true;
  5.  
  6. // SMTP port (default is 25; use 587 for STARTTLS or 465 for the
  7. // deprecated SSL over SMTP (aka SMTPS))
  8. $config['smtp_port'] = 587;
  9.  
  10. // SMTP username (if required) if you use %u as the username Roundcube
  11. // will use the current username for login
  12. $config['smtp_user'] = '%u';
  13.  
  14. // SMTP password (if required) if you use %p as the password Roundcube
  15. // will use the current user's password for login
  16. $config['smtp_pass'] = '%p';

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

  1. [02-Jan-2015 16:55:49 America/New_York] STARTTLS Failed ():
  2. [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日志显示

  1. [02-Jan-2015 17:50:01 -0500]: Recv: 220 example.net ESMTP Postfix
  2. [02-Jan-2015 17:50:01 -0500]: Send: EHLO example.net
  3. [02-Jan-2015 17:50:01 -0500]: Recv: 250-example.net
  4. [02-Jan-2015 17:50:01 -0500]: Recv: 250-PIPELINING
  5. [02-Jan-2015 17:50:01 -0500]: Recv: 250-SIZE 104857600
  6. [02-Jan-2015 17:50:01 -0500]: Recv: 250-VRFY
  7. [02-Jan-2015 17:50:01 -0500]: Recv: 250-ETRN
  8. [02-Jan-2015 17:50:01 -0500]: Recv: 250-STARTTLS
  9. [02-Jan-2015 17:50:01 -0500]: Recv: 250-ENHANCEDSTATUSCODES
  10. [02-Jan-2015 17:50:01 -0500]: Recv: 250-8BITMIME
  11. [02-Jan-2015 17:50:01 -0500]: Recv: 250 DSN
  12. [02-Jan-2015 17:50:01 -0500]: Send: STARTTLS
  13. [02-Jan-2015 17:50:01 -0500]: Recv: 220 2.0.0 Ready to start TLS
  14. [02-Jan-2015 17:50:01 -0500]: Send: RSET
  15. [02-Jan-2015 17:50:01 -0500]: Recv: M I A"qhçR¸
  16. [02-Jan-2015 17:50:01 -0500]: Send: QUIT

以下是/etc/postfix/main.cf中我的postfix配置的相关片段

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

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

  1. smtp inet n - - - - smtpd
  2. -o content_filter=spamassassin
  3. submission inet n - n - - smtpd
  4. -o syslog_name=postfix/submission
  5. -o smtpd_tls_security_level=encrypt
  6. -o smtpd_sasl_auth_enable=yes
  7. -o cleanup_service_name=cleanup_submit
  8. smtps inet n - - - - smtpd
  9. -o content_filter=spamassassin
  10. -o syslog_name=postfix/smtps
  11. -o smtpd_tls_wrappermode=yes
  12. -o smtpd_sasl_auth_enable=yes
  13. -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  14. -o milter_macro_daemon_name=ORIGINATING

后缀日志/var/log/mail.log报告以下错误

  1. Jan 2 17:50:01 example postfix/submission/smtpd[19959]: connect from localhost.localdomain[127.0.0.1]
  2. Jan 2 17:50:01 example postfix/submission/smtpd[19959]: SSL_accept error from localhost.localdomain[127.0.0.1]: 0
  3. 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:
  4. Jan 2 17:50:01 example postfix/submission/smtpd[19959]: lost connection after STARTTLS from localhost.localdomain[127.0.0.1]
  5. Jan 2 17:50:01 example postfix/submission/smtpd[19959]: disconnect from localhost.localdomain[127.0.0.1]

我已经阅读了一些其他类似错误代码的问题,但它们似乎都使用了自签名证书,或者我已经尝试过的adding a link to the certificate’s hash from /etc/ssl/certs/,尽管我可能错过了解,并且链接错误的证书.

Roundcube更新到1.0.4,这应该解决由于openssl导致PHP版本不兼容的问题.我完全没有想法,任何人都有任何想法?

上面的错误消息看起来像客户端(圆形立方体调用PHP脚本) fails to verify peer certificate because unknown CA.发生此错误的原因有很多.

关于openssl,Roundcube版本1.0-RC和更高版本附带SSL连接选项.参数smtp_conn_options和imap_conn_options分别在版本1.0-RC和1.0.3中添加.默认情况下,两个参数的值均为null.下面的代码段取自roundcube文件config / defaults.inc.PHP.您可以参考PHP manual以获得此参数的完整描述.

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

在许多使用自签名证书的系统中,默认值适用于PHP 5.5及更早版本.默认情况下,PHP 5.6 will verify peer certificate against installed CA and verify the peer name.

现在,看起来像Debian jessie也是shipped with default PHP version 5.6.显然PHP无法验证postfix证书.可能的原因,PHP在verify_peer_name中失败(因为您在hostname中指定了localhost)或者在verify_peer中失败了(因为CA未知)

类似的情况也发生在to Arch Linux user.解决方案是:

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

猜你在找的PHP相关文章