我試圖用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