2014-10-29 4 views
0

PHP에서 cURL을 사용하여 tls 연결을 통해 명시적인 ftp로 파일을 업로드하려고합니다. ftp 서버 인증은 성공하지만 수동 모드에서 파일을 업로드하려고하면 "server.domain.nl:21에 연결하는 중에 알 수없는 SSL 프로토콜 오류가 발생합니다."라는 오류가 표시됩니다.cURL을 포함한 ftp 업로드에서 알 수없는 SSL 프로토콜 오류

이 경우 어떤 문제가있을 수 있습니까? 수동 업로드를위한 포트가 내 제공 업체에 의해 차단 될 수 있습니까? 파일 업로드를위한 포트를 변경할 수 있습니까?

내 웹 사이트 공급자가 ftp_ssl_connect를 지원하지 않아 해당 기능을 사용할 수 없습니다.

들으, 잭

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) ; 

답변

0

Could it be that the port for the passive upload is blocked by my provider?

이 공급자는 몇 나가는 포트를 허용 할 수 있지만 수 있습니다 의심. 공급자에게 물어보십시오.

Can i change the port for the file upload?

아니요,이 포트는 FTP 서버에 의해 결정됩니다. 당신이 확인해야

어떤 일이 : 문제가 TLS를 통한 FTP 관련이 있는지

  • 일반 FTP와 그것을 시도 밖으로 찾을 수 있습니다.
  • 다른 FTP 서버로 시도해보십시오.
  • 다른 프로그램으로 서버에 연결해보십시오. 그것과는 별도로

:

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

왜 당신이 어쨌든 피어의 유효성 검사를 비활성화하는 모든 때문에 TLS 사용합니까? 아니면 테스트 용입니까?

+0

Thx. 공급자에게 나가는 포트를 허용하는지 물어 봅니다. ftp_connect()를 사용하여 다른 ftp 서버로 시도해 보았습니다. 나는 cURL을 사용하여 다른 서버에 연결하려고 시도 할 것입니다. 아마 저에게 새로운 정보를 줄 것입니다. – sjaksan

관련 문제