无法使用curl连接到FTPS TLS / SSL隐式加密

问题描述 投票:1回答:1

我有一个PHP实用程序,使用ftp_connect()连接和下载/上传FTPS文件,它在我的本地机器上工作正常。但是上传到GCP VM的相同代码(CentOS 7)没有连接到FTPS。我为FTP打开了端口990和5000-5016。

$ftp_conn = ftp_connect(FTP_SERVER,990) or die("Could not connect to ".FTP_SERVER);
$login = ftp_login($ftp_conn, base64_decode($ftp_user), base64_decode($ftp_pass));

因此,作为一种解决方法,我想使用curl命令连接到FTPS服务器。

curl -v -k --ftp-pasv --user user:pass ftps://myftps.com:990/ -v --trace trace.txt -3

curl即使在我的本地机器上也不起作用。请在下面找到跟踪响应

=> Send header, 5 bytes (0x5)
0000: 50 57 44 0d 0a                                  PWD..
<= Recv header, 30 bytes (0x1e)
0000: 32 35 37 20 22 2f 22 20 69 73 20 63 75 72 72 65 257 "/" is curre
0010: 6e 74 20 64 69 72 65 63 74 6f 72 79 0d 0a       nt directory..
== Info: Entry path is '/'
=> Send header, 6 bytes (0x6)
0000: 45 50 53 56 0d 0a                               EPSV..
== Info: Connect data stream passively
== Info: ftp_perform ends with SECONDARY: 0
<= Recv header, 26 bytes (0x1a)
0000: 35 30 30 20 55 6e 6b 6e 6f 77 6e 20 63 6f 6d 6d 500 Unknown comm
0010: 61 6e 64 20 45 50 53 56 0d 0a                   and EPSV..
== Info: Failed EPSV attempt. Disabling EPSV
=> Send header, 6 bytes (0x6)
0000: 50 41 53 56 0d 0a                               PASV..
<= Recv header, 52 bytes (0x34)
0000: 32 32 37 20 45 6e 74 65 72 69 6e 67 20 50 61 73 227 Entering Pas
0010: 73 69 76 65 20 4d 6f 64 65 20 28 31 37 32 2c 32 sive Mode (172,2
0020: 31 2c 32 35 33 2c 32 35 34 2c 31 39 2c 31 33 36 1,253,254,19,136
0030: 29 2e 0d 0a                                     )...
== Info:   Trying xxx.xx.xx.x ...
== Info: Connecting to xxx.xx.xx.x (xxx.xx.xx.x) port 5000
== Info: Connection timed out
== Info: Failed connect to myftps.com:990; Connection timed out
== Info: Closing connection 0

任何帮助将不胜感激。谢谢

php curl ftp centos7 ftps
1个回答
0
投票

ftp_connect从不使用TLS / SSL。无论你是否连接到990端口,它都可能永远不会工作,尽管你声称它“在我的本地机器上工作正常” - 是不可能的。


PHP FTP函数甚至不支持隐式TLS / SSL。

但几乎所有FTPS服务器都支持显式TLS / SSL。

为此,使用带有默认端口21的ftp_ssl_connect


如果你真的需要使用隐式TLS / SSL(我怀疑),你需要使用另一个FTP实现,比如curl。另见ftp_ssl_connect with implicit ftp over tls

我知道curl也不适合你,但是使用curl你会遇到一个非常不同的问题(即使使用带有显式TLS / SSL的PHP​​ FTP功能,你最终也可能会遇到这个问题)。这是一个单独的问题。请注意,curl确实连接。您可以在跟踪中清楚地看到curl从FTP服务器收到了大量响应。

© www.soinside.com 2019 - 2024. All rights reserved.