[英]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 0PBSZ 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 avsCWD视音频
< 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: noneCApath:无
* 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: 您应该检查一些事情:
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.