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.
Open the file browser on your computer and select File > Connect to Server... A window pops up where you can select the service type (i.e. FTP, FTP with login or SSH), enter the server address and your username. If you're going to authenticate as a user, be sure to enter your username in this screen already.
Open the endpoint for this FTPS server. Verify the following login credentials for the FTPS connection: FTP server, Port, User, and Password. Click Test Connection. If the connection is successful, use this endpoint in Studio orchestrations, then use the Verify tab features to evaluate the orchestration.
FTPS stands for file transfer protocol SSL (secure sockets locker). SSL is a cryptographic protocol that encrypts the data being transferred. The term SSL is generally used interchangeably with TLS or transport layer security, with TLS v1. 2 actually being the most current non-vulnerable protocol.
I think, you have a real reason to re-invent the wheel. Already there are libraries which implements FTPS server in C#/.NET, like SecureBlackbox (however, it is commercial).
Please have a look at a workaround I posted here. It would be great if all together we could make this workaround better.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With