FTPS Server Using .NET SslStream

I am developing an FTP server in C #, I just finished implementing the FTPS explicit mode functions using the class SslStream, and everything is going almost fine.

I'm having problems using fileZilla> 3.0.11 as a client. I am google arround and it seems that the implementation SslStreamdoes not close the connection properly. (does not send a warning close_notify). Using WinScp, SmartFTP and lftp everithing works great.

Any ideas or any other SSL library?

Or maybe some way to tune the alert close_notifyand send it?

Sample code for concrete will 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.
+5
4

, . , FTPS #/. NET, SecureBlackbox ( ).

+5

, , . , .

+3

What happens if you call Shutdown on a Socket before closing it?

socket.Shutdown(SocketShutdown.Both);
0
source

What about

_sslStream.Dispose();

I am wondering if the Dispose method handles close_notify.

0
source

All Articles