我正在尝试通过 FTPS 使用 cURL 下载目录及其文件。
以下命令让我非常接近 - 我成功登录并设置了清除命令通道,但随后失败了curl: (56) response reading failed
curl -v --ftp-ssl --data-ascii --ftp-pasv --no-epsv --user myusername:XXXXXXXX ftp://ftp.server.com:21 -Q "CCC"
* About to connect() to ftp.server.com port 21 (#0)*
Trying 55.55.55.55... connected
< 220-This System Is For Authorized Users Only.
< 220-
< 220 Secure FTP Server - SecureTransport ready.
> AUTH SSL
< 234 SSLv23/TLSv1
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using AES256-SHA
* Server certificate:
* subject: DC=local; DC=ftp_host_company; DC=us; OU=Accounts; OU=SSL Accounts; CN=ftp.server.com
* start date: 2012-02-14 16:29:37 GMT
* expire date: 2015-02-14 16:59:37 GMT
* common name: ftp.server.com (matched)
* issuer: DC=local; DC=ftp_host_company; CN=Configuration; CN=Services; CN=Public Key Services; CN=AIA; CN=FTP_hosting_company Issuing CA 1
* SSL certificate verify ok.
> USER myusername
< 331 Password required for myusername.
> PASS XXXXXXXX
< 230 Virtual user myusername logged in.
> PBSZ 0
< 200 PBSZ=0
> PROT P
< 200 PROT command successful
> PWD
< 257 "/" is current directory.
* Entry path is '/'
> CCC
< 200 command channel cleared.
> PASV
* Connect data stream passively
* SSLv3, TLS alert, Client hello (1):
* response reading failed
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):
curl: (56) response reading failed
ftps 主机明确指出我需要通过端口 21 上的 Clear Command Channel 连接 FTPS - 我遗漏了什么吗?
答案1
CCC 用于将命令通道从 SSL 降级回纯文本,即在收到对 CCC 的成功响应后,双方都必须在套接字上执行 SSL_shutdown。因此,curl 必须处理命令的固有语义,而让 curl 像处理任何其他任意命令一样发送此命令是不够的。相反,您必须使用该--ftp-ssl-ccc
选项。