简体   繁体   English

使用cURL的ftp上传中的未知SSL协议错误

[英]Unknown SSL protocol error in a ftp upload with cURL

I'm trying to upload a file with an explicit ftp over tls connection, using cURL in PHP. 我正在尝试使用PHP中的cURL通过tls连接通过显式ftp上传文件。 The authentication with the ftp server succeeds, but when i try to upload the file in passive mode, i receive the following error: "Unknown SSL protocol error in connection to server.domain.nl:21". ftp服务器的身份验证成功,但是当我尝试以被动方式上传文件时,出现以下错误:“与server.domain.nl:21连接时出现未知SSL协议错误”。

What can be the issue in this case? 在这种情况下可能是什么问题? Could it be that the port for the passive upload is blocked by my provider? 被动上传的端口可能被我的提供商阻止了吗? Can i change the port for the file upload? 我可以更改文件上传的端口吗?

My website provider doesn't support ftp_ssl_connect, so i cannot use that function. 我的网站提供商不支持ftp_ssl_connect,所以我不能使用该功能。

Thx, Jack 杰克(Thx)

FTP Log: FTP日志:

230 User logged in. 230用户登录。
PBSZ 0 PBSZ 0
< 200 PBSZ command successful. <200 PBSZ命令成功。
PROT P 保护
< 200 PROT command successful. <200 PROT命令成功。
PWD 残障人士
< 257 "/" is current directory. <257“ /”是当前目录。
* Entry path is '/' *输入路径为“ /”
CWD avs CWD视音频
< 250 CWD command successful. <250 CWD命令成功。
EPSV 电动汽车
* Connect data stream passively *被动连接数据流
< 229 Entering Extended Passive Mode (|||50075|) <229进入扩展被动模式(||| 50075 |)
* Trying xxxx.. *正在尝试xxxx ..
* Connecting to xxxx (xxxx) port 50075 *连接到xxxx(xxxx)端口50075
TYPE I 第一类
< 200 Type set to I. <200类型设置为I。
STOR 00191_2773.xml < 150 Opening BINARY mode data connection. STOR 00191_2773.xml <150打开BINARY模式数据连接。
* Doing the SSL/TLS handshake on the data stream *在数据流上进行SSL / TLS握手
* successfully set certificate verify locations: *成功设置证书验证位置:
* CAfile: c:\\vevida\\php54\\cacert.pem * CAfile:c:\\ vevida \\ php54 \\ cacert.pem
CApath: none CApath:无
* SSL re-using session ID * SSL重用会话ID
* Unknown SSL protocol error in connection to server.domain.nl:21 *连接server.domain.nl:21时发生未知的SSL协议错误
* Closing connection 19 *闭合连接19

My code is: 我的代码是:

$ch = curl_init() ;

    $stderr = fopen("d:\\www\\domein.nl\\www\\pdf\\temp\\curl.txt", "w"); 
    $fp = fopen($fileLocation191, 'r') ;

    //logging:
    curl_setopt($ch, CURLOPT_VERBOSE, TRUE) ;
    curl_setopt($ch, CURLOPT_STDERR, $stderr) ;

    curl_setopt($ch, CURLOPT_URL, 'ftp://user:pw@server.domein.nl/avs/'.$remote_file191) ;  
    curl_setopt($ch, CURLOPT_UPLOAD, TRUE) ;
    curl_setopt($ch, CURLOPT_INFILE, $fp) ;
    curl_setopt($ch, CURLOPT_INFILESIZE, filesize($fileLocation191)) ;

    curl_setopt($ch, CURLOPT_PORT, 21) ;
    curl_setopt($ch, CURLOPT_USERPWD, 'user:pw');

    // SSL STUFF        
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false) ;
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false) ;
    curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1) ; 
    curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'TLSv1') ;  
    curl_setopt($ch, CURLOPT_FTP_SSL, CURLOPT_FTPSSLAUTH) ; 
    curl_setopt($ch, CURLOPT_FTPSSLAUTH, CURLFTPAUTH_TLS) ;             
    // EINDE SSL 

    //curl_setopt($ch, CURLOPT_FTPPORT, '-') ; 
    curl_setopt($ch, CURLOPT_TIMEOUT, 30) ;
    curl_setopt($ch, CURLOPT_FTP_USE_EPSV, TRUE) ;
    curl_setopt($ch, CURLOPT_FTP_USE_PASV, TRUE) ;
    curl_setopt($ch, CURLOPT_FTP_USE_EPRT, FALSE) ;


    curl_exec ($ch) ;

Could it be that the port for the passive upload is blocked by my provider? 被动上传的端口可能被我的提供商阻止了吗?

It can be that the provider only allows few outgoing ports, but I doubt it. 提供程序可能只允许很少的传出端口,但我对此表示怀疑。 Ask the provider. 询问提供者。

Can i change the port for the file upload? 我可以更改文件上传的端口吗?

No, this port is determined by the FTP server. 否,此端口由FTP服务器确定。

Some thing you should check: 您应该检查一些事情:

  • Try it with plain FTP to find out if the problem is related to FTP over TLS. 尝试使用普通FTP来查找问题是否与基于TLS的FTP有关。
  • Try it with a different FTP server. 尝试使用其他FTP服务器。
  • Try to reach the server with a different program. 尝试使用其他程序访问服务器。

Apart from that: 除此之外:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false) ;
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false) ;

Why do you use TLS at all since you are disabling validation of the peer anyway? 由于无论如何都禁用对等方的验证,为什么要完全使用TLS? Or is this only for testing? 还是仅用于测试?

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

相关问题 Curl:未知的SSL协议错误gcm - Curl:Unknown SSL protocol error gcm PHP cURL“与连接有关的未知SSL协议错误” - PHP cURL “Unknown SSL protocol error in connection to” PHP curl 错误:“连接到……的未知 SSL 协议错误” - PHP curl error: “Unknown SSL protocol error in connection to…” 在服务器中卷曲“连接中的未知SSL协议错误”错误,但在本地工作 - curl “Unknown SSL protocol error in connection” error in server, but works on local cURL PHP错误:连接中未知的SSL协议错误 - cURL PHP ERROR: Unknown SSL protocol error in connection 错误-PHP-cURL-连接中的未知SSL协议错误- - Error - PHP - cURL - Unknown SSL protocol error in connection - curl:(35)与连接相关的未知SSL协议错误-调用Web服务时出错 - curl: (35) Unknown SSL protocol error in connection to - Error in calling webservices CURL错误:140770FC:SSL例程:SSL23_GET_SERVER_HELLO:未知协议 - CURL error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol HTTP错误:cURL错误:35:cakephp中的连接nusoap中的未知SSL协议错误 - HTTP Error: cURL ERROR: 35: Unknown SSL protocol error in connection nusoap in cakephp cURL 错误 35 - 与 api.rkd.reuters.com:443 相关的未知 SSL 协议错误 - cURL error 35 - Unknown SSL protocol error in connection to api.rkd.reuters.com:443
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM