EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Implicit FTP over TLS

Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.
#29683
Posted: 06/04/2014 12:01:27
by Sean Taylor (Priority Standard support level)
Joined: 12/18/2013
Posts: 11

I am trying setup an implicit FTP over TLS connection but am getting the following error.

Code
Control channel transfer error


Here is my code. What could be the issue?

Code
public TElSimpleFTPSClient GetFtpsClient(string endpoint, string username, string password, int
            port = 21, bool useSsl = false, bool passiveMode = false, TSBSSLMode sslMode = TSBSSLMode.smExplicit)
        {
            var client = new TElSimpleFTPSClient
            {
                Address = endpoint,
                Port = port,
                Username = username,
                Password = password,
                Versions = 0,
                UseSSL = useSsl,
                PassiveMode = passiveMode,
                SSLMode = sslMode,
                SocketTimeout = 999999,
                TransferTimeout = 999999
            };

            client.Open();
            client.Login();
            
            return client;
        }
#29684
Posted: 06/04/2014 12:39:49
by Eugene Mayevski (EldoS Corp.)

Port 21 is used with Explicit mode. If you need to use Implicit mode, you need to set port and sslMode parameters of your method accordingly -- port must be set to 990 or alternative port if you know it, and sslMode should be set to smImplicit. Also useSsl must be set to true.


Sincerely yours
Eugene Mayevski
#29691
Posted: 06/04/2014 21:07:12
by Sean Taylor (Priority Standard support level)
Joined: 12/18/2013
Posts: 11

I have set those parameters as you have indicated and now I get an error on the following line.

Code
client.Open();


The error is {"Invalid SSL version"}
#29692
Posted: 06/05/2014 01:13:28
by Vsevolod Ievgiienko (EldoS Corp.)

The reason is that TElSimpleFTPSClient.Versions property is set to 0. Please change its value according to the documentation: https://www.eldos.com/documentation/sb...sions.html
#29698
Posted: 06/05/2014 08:15:35
by Sean Taylor (Priority Standard support level)
Joined: 12/18/2013
Posts: 11

Thanks. I got past that error and was faced with another one that said

Quote
Certificate validation handler is not assigned. Please handle the OnCertificateValidate event and implement proper certificate validation code there.


So I implemented the handler like this. It works but not sure if it is the correct way to handle it.

Code
public TElSimpleFTPSClient GetFtpsClient(string endpoint, string username, string password, int
            port = 21, bool useSsl = false, bool passiveMode = false, TSBSSLMode sslMode = TSBSSLMode.smExplicit)
        {
            var client = new TElSimpleFTPSClient
            {
                Address = endpoint,
                Port = port,
                Username = username,
                Password = password,
                UseSSL = useSsl,
                PassiveMode = passiveMode,
                SSLMode = sslMode,
                SocketTimeout = 999999,
                TransferTimeout = 999999
            };

            client.OnCertificateValidate += ftpsClient_OnCertificateValidate;
            client.Open();
            client.Login();
            
            return client;
        }

        private void ftpsClient_OnCertificateValidate(object sender, TElX509Certificate x509certificate, ref bool validate)
        {
            validate = true;
        }
#29704
Posted: 06/05/2014 23:55:02
by Vsevolod Ievgiienko (EldoS Corp.)

This is correct only for testing purposes. Please refer to our SSL-enabled samples that contain implementation that may be used in production.
#29716
Posted: 06/06/2014 19:25:15
by Sean Taylor (Priority Standard support level)
Joined: 12/18/2013
Posts: 11

So I have managed to connect and login to the ftp server. Now I am trying to send a file to the server but am getting the following error when using the SEND command. The error is...

Quote
{"Unaccepted server reply (error code is 522)"}


I am using the client created in the code above with IMPLICIT mode, port 990 and useSsl set to true.
#29717
Posted: 06/06/2014 23:54:38
by Eugene Mayevski (EldoS Corp.)

IIRC this error code is not valid for any command sent during file transfer. Please run our sample application, try to upload the file and then capture the log that the application creates and post the log here, so that we could understand, which command causes such non-standard response.


Sincerely yours
Eugene Mayevski
#29718
Posted: 06/07/2014 00:08:40
by Eugene Mayevski (EldoS Corp.)

Also 5xx codes are error codes, i.e. they indicate the error which is fatal for the requested operation. So the exception itself is correct and your code must handle such error. See the log for additional information about why it happens.


Sincerely yours
Eugene Mayevski
#29735
Posted: 06/09/2014 11:07:40
by Sean Taylor (Priority Standard support level)
Joined: 12/18/2013
Posts: 11

I am not able to connect when I try with the sample application. I get the following error.

Quote
Wrong socket state 4 in SetAddress (error code is 96258)
Also by EldoS: Callback File System
Create virtual file systems and disks, expose and manage remote data as if they were files on the local disk.

Reply

Statistics

Topic viewed 3085 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!