Página 1 de 1

Acesso ao FTP com TLS

Enviado: 21 Mar 2019 15:38
por Toledo
Amigos, estou desenvolvendo um sistema que tem que enviar um arquivo TXT via FTP para uma pasta no servidor, mas o FTP deste servidor tem criptografia (TLS) para conexão. Eu estou usando o Harbour 3.2 e não estou conseguindo fazer o acesso. Estou usando a função abaixo:

Código: Selecionar todos

Function FtpConnect()
   Local cUser:= cPassWord:= cServer:= cUrl:= []

   cUser    := "xxxxxx1"
   cPassWord:= "xaxaxaF"
   cServer  := "ftp.xxxxxxxx.com.br"
   cUrl     := "ftp://" + Alltrim(cUser) + ":" + Alltrim(cPassWord) + "@" + Alltrim(cServer)

   oUrl:= tURL():New(cUrl)
   If Empty(oUrl)
      Msginfo("Endereço Inexistente")
      Return (.F.)
   Endif

   oClient:= TIpClientFtp():New(oUrl, .T.)
   If Empty(oClient)
      Msginfo("Sem Conexão")
      Return (.F.)
   Endif

   oClient:nConnTimeout  := 20000
   oClient:bUsePasv      := .T.
   oClient:oUrl:cUserID  := cUser
   oClient:oUrl:cServer  := cServer
   oClient:oUrl:cPassword:= cPassWord

   If oClient:Open()    //Aqui que nao esta funcionando
      If Empty(oClient:cReply)
         oClient:Pasv()
      Else
         oClient:Pasv()
      Endif
   Else
      Msginfo("Não abri conexão")
      Return (.F.)
   Endif
Return (.T.)
No arquivo de LOG criado, está retornando:
20190321-14:01:05 :INETCONNECT( ftp.xxxxxxx.com.br, 21 )
>> <pointer> <<

20190321-14:01:05 :INETERRORCODE( <pointer> )
>> 0 <<

20190321-14:01:05 :INETRECVLINE( <pointer>, , 128 )
>> 220 (vsFTPd 3.0.2) <<

20190321-14:01:05 :INETERRORCODE( <pointer> )
>> 0 <<

20190321-14:01:05 :INETSENDALL( <pointer>, 15, USER xxxxxxx1<cr><lf> )
>> 15 <<

20190321-14:01:05 :INETRECVLINE( <pointer>, , 128 )
>> 530 Non-anonymous sessions must use encryption. <<

20190321-14:01:05 :INETERRORCODE( <pointer> )
>> 0 <<
Alguém no Harbour já conseguiu conectar num servidor FTP com criptografia (TLS)?

Abraços

Acesso ao FTP com TLS

Enviado: 21 Mar 2019 16:21
por asimoes
Toledo,

Quando eu tinha o serviço da Kinghost, era assim que eu utilizava o ftp

Código: Selecionar todos

         WITH OBJECT oFTP :=  TIPclientFTP():New( ::oURL, .F. )
               :nConnTimeout   := ::nTimeOut
               :bUsePasv       := ::lUsePasv
               :oUrl:cServer   := ::cServer
               :oUrl:cUserID   := ::cUser
               :oUrl:cPassword := ::cPassword
               :nDefaultPort   := ::nPorta 
               IF :Open()
                  :Cwd("/")
                  :Cwd(::cPastaFTP)     // muda o diretorio no FTP
                  FOR EACH oElemento IN :listFiles( "*.*" )
                      :DownLoadFile( cPastaLocal + oElemento[1], oElemento[1] )  // baixa o arquivo versão.txt dentro da pasta update
                      FileStats( cPastaLocal + oElemento[1], ;
                                 @cFileAttr, ;
                                 @nFileSize, ;
                                 @dCreateDate, ;
                                 @nCreateTime, ;
                                 @dChangeDate, ;
                                 @nChangeTime  )
                      :dele( oElemento[1] ) //deleta o arquivo no ftp
                      ::nTotal += nFileSize
                      ::lArqDn:=.T.
                      oClPF:SysWait(3)
                  NEXT
                  IF ::lArqDn
                     ::lSucessoDownload := .T.
                     :Commit()
                  ENDIF
                  :Close()
               ELSE 
                  oMonitor:Notificar( "Erro, baixando " + :lastErrorMessage(), "Monitor AsaPrev", , 3 )
                  //MsgStop(oFTP:lastErrorMessage(), "erro no open")
               ENDIF
            END

Acesso ao FTP com TLS

Enviado: 21 Mar 2019 16:26
por Nascimento
achei neste link aqui veja se lhe é util

https://groups.google.com/forum/#!searc ... fG3A_9OjkJ

Acesso ao FTP com TLS

Enviado: 22 Mar 2019 11:32
por JoséQuintas
Dá uma olhada se tem exemplo na pasta tests da hblibcurl

Não sei se vai depender de atualizar Windows, porque o W7 não em isso se não for atualizado e configurado.