Using FTPS
Closed this issue · 7 comments
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));
}
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.
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
.
Thanks, I'll check this and let you know.
I juste released a version 1.11, which has lazy Stream
(SSL is initialized after response from server). Can you test it?
Works great with my FTP server.
@Slinger1731 could you check the latest version works for you?