ArxOne / FTP

Simple FTP client
MIT License
37 stars 15 forks source link

Using FTPS #27

Closed Slinger1731 closed 6 years ago

Slinger1731 commented 8 years ago

When I attempt to connect to azure and use List the library waits returning nothing. The end result is the host closes the connection. Is this a bug or am I missing a setup step to use secure connections?

using (var client = new FtpClient(new Uri(_address), new NetworkCredential(_userName, _password), new FtpClientParameters {SslProtocols = SslProtocols.Tls})) {

            var pro = client.Protocol;

            return client.List(new FtpPath(BaseDirectory));

        }
picrap commented 8 years ago

Hi,

i had this kind of problem and was not able to solve it for all FTP servers. Usually it is a protocol issue, so what you did (setting the SslProtocols property) seems right. You may also try some FTPES (if available and see if it works better). Sorry about that, any idea welcome...

Pascal.

picrap commented 7 years ago

Related to #32

ebarnard commented 7 years ago

The issue seems to be that SslStream.AuthenticateAsClient is called by OpenDataStream before the client sends a command that returns data.

AuthenticateAsClient blocks until the TLS handshake is complete or the read on the socket times out.

Most FTP servers will not send anything (including their part of the TLS handshake) to the data stream socket until the client sends a command.

Therefore OpenDataStream blocks until the socket times out.

A solution would be to have OpenDataStream return an object that can be resolved to an FtpStream once a command is sent. At this point AuthenticateAsClient would be called for a PassiveFtpStream.

picrap commented 7 years ago

Thanks, I'll check this and let you know.

picrap commented 7 years ago

I juste released a version 1.11, which has lazy Stream (SSL is initialized after response from server). Can you test it?

ebarnard commented 7 years ago

Works great with my FTP server.

picrap commented 7 years ago

@Slinger1731 could you check the latest version works for you?