曾几何时,PHP 领域有一个正常的错误:
Once upon a time, there was a normalish error in PHP land:
警告:ftp_nlist(): data_accept: SSL/TLS 握手在第 29 行的 [path] 中失败
Warning: ftp_nlist(): data_accept: SSL/TLS handshake failed in [path] on line 29
但这里有一个问题,第 29 行".不是连接或登录,注意它是如何引用 ftp_nlist()
函数的:
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 在 phpinfo()
中编译并启用,如下所示:ftp_login() : SSL/TLS 握手失败
OpenSSL is compiled and enabled in phpinfo()
as suggested here:
ftp_login() : SSL/TLS handshake failed
我看到的其他帖子似乎都引用了适合我的 ftp_ssl_connect()
或 ftp_login()
命令中的错误.当 ftp_login()
返回 true 时我可以检查什么?
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?
我使用的是 php 5.3.29.该代码在我的桌面(php 7)上可以正常工作,但我希望我不必将服务器升级到 7 即可工作
I'm using php 5.3.29. The code does work properly on my desktop (php 7), but I'm hoping I don't have to upgrade the server to 7 for this to work
2017 年 12 月 28 日更新:升级到 5.6 解决了,所以看起来 Martin 是正确的.
12-28-2017 update: Upgrading to 5.6 resolved, so looks like Martin is on point.
ftp_nlist
打开一个数据连接.该连接也需要 TLS/SSL 握手.
The ftp_nlist
opens a data connection. That connection needs TLS/SSL handshake too.
由于控制连接握手成功,问题确实不在于 PHP 中缺少 TLS/SSL 支持.问题不在于服务器和 PHP 无法找到一致的密码.
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.
当控制连接握手成功后数据连接上的 TLS/SSL 握手失败时,通常是因为客户端 (PHP) 没有从数据连接上的控制连接重用 TLS/SSL 会话(请参阅 为什么会话重用在 FTPS 中有用?).有些服务器确实需要.PHP 仅从 5.6.26 开始支持重用.请参阅 PHP 错误 70195.因此,请确保您至少使用该版本的 PHP.
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.
这篇关于ftp_nlist(): data_accept: SSL/TLS 握手失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!