我试图用PHP中的cURL上传一个带有明确ftp over tls连接的文件。与ftp服务器的身份验证成功,但是当我尝试以被动模式上载文件时,我收到以下错误:“连接到server.domain.nl:21的未知SSL协议错误”。用cURL上传ftp上传的未知SSL协议错误
在这种情况下会出现什么问题?难道被动上传的端口被我的提供商阻止了吗?我可以更改文件上传的端口吗?
我的网站提供商不支持ftp_ssl_connect,所以我不能使用该功能。
THX, 杰克
FTP日志:
230 User logged in.
PBSZ 0
< 200 PBSZ command successful.
PROT P
< 200 PROT command successful.
PWD
< 257 "/" is current directory.
* Entry path is '/'
CWD avs
< 250 CWD command successful.
EPSV
* Connect data stream passively
< 229 Entering Extended Passive Mode (|||50075|)
* Trying x.x.x.x...
* Connecting to x.x.x.x (x.x.x.x) port 50075
TYPE I
< 200 Type set to I.
STOR 00191_2773.xml < 150 Opening BINARY mode data connection.
* Doing the SSL/TLS handshake on the data stream
* successfully set certificate verify locations:
* CAfile: c:\vevida\php54\cacert.pem
CApath: none
* SSL re-using session ID
* Unknown SSL protocol error in connection to server.domain.nl:21
* Closing connection 19
我的代码是:
$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:[email protected]/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) ;
Thx。我会问我的供应商是否允许输出端口。我已经用ftp_connect()与不同的ftp服务器一起尝试过,并且工作正常。我会尝试用cURL连接不同的服务器,也许这会给我新的信息.. – sjaksan 2014-10-29 17:38:00