I'm developing a FTP server in C#, I just finished implementing FTPS explicit mode functionality using SslStream
class and everything goes almost ok.
I'm having problems using fileZilla > 3.0.11 as client. I google arround, and it seems that sslstream
implementation does not close the connection properly. (not sending close_notify
alert). Using WinScp, SmartFTP and lftp everithing works fine.
Any ideas or any other SSL library?
Or maybe some way to hardcode the close_notify
alert and send it?
Concrete code example would be great!
Creating sslStream:
_sslStream = new SslStream(socket.GetStream());
var _cert = new X509Certificate2(certPath,pass);
_sslStream.AuthenticateAsServer(_cert);
Closing connections:
_sslStream.Close();
socket.Close();
_sslStream = null;
socket = null;
FileZilla 3.6.0.2 Error log:
Response: 150 Opening data connection for LIST
Trace: CFtpControlSocket::TransferParseResponse()
Trace: code = 1
Trace: state = 4
Trace: CFtpControlSocket::SendNextCommand()
Trace: CFtpControlSocket::TransferSend()
Trace: state = 5
Trace: CTlsSocket::OnRead()
Trace: CTlsSocket::ContinueHandshake()
Trace: TLS Handshake successful
Trace: TLS Session resumed
Trace: Cipher: AES-128-CBC, MAC: SHA1
Trace: CTransferSocket::OnConnect
Trace: CTransferSocket::OnReceive(), m_transferMode=0
Trace: CTlsSocket::Failure(-110, 0)
Error: GnuTLS error -110 in gnutls_record_recv: The TLS connection was non-properly terminated.
Error: Could not read from transfer socket: ECONNABORTED - Connection aborted
Trace: CTransferSocket::TransferEnd(3)
Trace: CFtpControlSocket::TransferEnd()
Trace: CTlsSocket::OnRead()
Trace: CFtpControlSocket::OnReceive()
Response: 226 LIST successful.