简体   繁体   English

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

[英]Unable to connect to FTPS TLS/SSL Implicit encryption using curl

I have a PHP Utility which connects and download/uploads file from/to FTPS using ftp_connect() and it works fine on my local machine. 我有一个PHP实用程序,可以使用ftp_connect()从FTPS连接和下载文件/将文件上传到FTPS,并且在我的本地计算机上可以正常工作。 But with the same code uploaded to GCP VM (CentOS 7) does not connect to FTPS. 但是,使用相同的代码上传到GCP VM(CentOS 7)不会连接到FTPS。 I've opened port 990 and 5000-5016 for FTP. 我已经为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));

So as a work around, I want to use curl command to connect to FTPS server. 因此,作为解决方法,我想使用curl命令连接到FTPS服务器。

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

But curl does not work even on my local machine. 但是,即使在我的本地计算机上, curl也不起作用。 Please find below response of trace 请在下面找到跟踪响应

=> 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

Any help will be appreciated. 任何帮助将不胜感激。 Thanks 谢谢

ftp_connect never uses TLS/SSL. ftp_connect从不使用TLS / SSL。 No matter if you connect to port 990. It could have never worked, despite your claim that it "works fine on my local machine" - impossible. 无论您是否连接到端口990,它都永远无法工作,尽管您声称它“在我的本地计算机上运行良好” -不可能。


PHP FTP functions do not even support implicit TLS/SSL. PHP FTP函数甚至不支持隐式TLS / SSL。

But virtually all FTPS servers support explicit TLS/SSL. 但实际上,所有FTPS服务器都支持显式TLS / SSL。

For that use ftp_ssl_connect with the default port 21. 为此,请使用ftp_ssl_connect和默认端口21。


If you really need to use implicit TLS/SSL (I doubt), you need to use another FTP implementation, like the curl . 如果确实需要使用隐式TLS / SSL(我怀疑),则需要使用其他FTP实现,例如curl See also ftp_ssl_connect with implicit ftp over tls . 另请参见ftp_ssl_connect和基于tls的隐式ftp

I'm aware that curl does not work for you either, but with curl you have a very different problem (which you will possibly eventually face even with PHP FTP function with explicit TLS/SSL). 我知道curl也不适合您,但是curl有一个非常不同的问题(即使使用带有显式TLS / SSL的PHP​​ FTP函数,您最终也可能会遇到该问题)。 And that's for a separate question. 这是一个单独的问题。 Note that curl actually does connect . 请注意, curl实际上确实可以连接 You can clearly see in your trace that curl received lot of responses from the FTP server. 您可以在跟踪中清楚地看到curl收到了来自FTP服务器的大量响应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM