ftp_nlist(): data_accept: SSL/TLS handshake failed

六眼飞鱼酱① 提交于 2019-12-08 08:14:29

问题


Once upon a time, there was a normalish error in PHP land:

Warning: ftp_nlist(): data_accept: SSL/TLS handshake failed in [path] on line 29

But here's the catch, "line 29" is not the connection or login, note how it referenced the ftp_nlist() function:

$ftp = ftp_ssl_connect($cred['host'], $cred['port'], 180);
if (!ftp_login($ftp, $cred['user'], $cred['pass'])) {die("Login Failed");}
ftp_pasv($ftp, true);

$files = ftp_nlist($ftp, '');

OpenSSL is compiled and enabled in phpinfo() as suggested here: ftp_login() : SSL/TLS handshake failed

Other posts I've seen all seem to reference error in the ftp_ssl_connect() or ftp_login() commands which work for me. What can I check when ftp_login() returns true?

Or... are there any logs to get more details on what is wrong?

12-28-2017 update: Upgrading to 5.6 resolved, so looks like Martin is on point.


回答1:


The ftp_nlist opens a data connection. That connection needs TLS/SSL handshake too.

As the control connection handshake succeeded, the problem indeed cannot be with an absent TLS/SSL support in PHP. Neither the problem can be with anything like the server and PHP not being able to find a cipher to agree on.

When TLS/SSL handshake on data connection fails after handshake on control connection succeeded, it's quite usually because the client (PHP) did not reuse TLS/SSL session from control connection on the data connection (see Why is session reuse useful in FTPS?). Some servers do require that. PHP supports the reuse only since 5.6.26. See PHP Bug 70195. So make sure you use that version of PHP at least.



来源:https://stackoverflow.com/questions/47635241/ftp-nlist-data-accept-ssl-tls-handshake-failed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!