Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make my delphi application use FTPS instead of FTP (indy)

Here's my program:

Application.FTP.Host:= vHost;
Application.FTP.Port:= vPort;
try
  Application.FTP.AutoLogin := false;
  Application.FTP.Connect;
  Application.FTP.IOHandler.RecvBufferSize := 2048;

I'm using TIdFTP component in Delphi XE3.

I think I have to use something like this...

 Application.FTP.UseTLS := utUseRequireTLS;

but the compiler doesn't like that line

How can I get my FTP application to use FTPS ?

like image 280
user1398287 Avatar asked Dec 20 '22 09:12

user1398287


2 Answers

First, do you need SFTP (FTP over SSH) or FTPS (FTP over SSL)? They are not the same thing. Indy does not support SSH at this time. For SSL, you can attach an SSL IOHandler, such as TIdSSLIOHandlerSocketOpenSSL, to the TIdFTP.IOHandler property and then set the TIdFTP.UseTLS property to anything other than utNoTLSSupport (yes, TIdFTP does have a UseTLS property). If you need to encrypt the actual file transfer connections, not just the command connection, then set the TIdFTP.DataPortProtection property to ftpdpsPrivate.

like image 62
Remy Lebeau Avatar answered Dec 24 '22 00:12

Remy Lebeau


With Indy10 you can add an TIdSSLIOHandlerSocketOpenSSL component and set FTP.IOHandler to point to this component.

And then in TIdSSLIOHandlerSocketOpenSSL you set your SSL options.

Ex.

ftpC.IOHandler:=iohFTPSE; //TIdSSLIOHandlerSocketOpenSSL 
ftpC.UseTLS:=utUseExplicitTLS;
ftpC.DataPortProtection:=ftpdpsPrivate;
like image 29
Daniel Avatar answered Dec 24 '22 00:12

Daniel