我正在用 C# 开发一个 FTP 服务器,我刚刚使用SslStream
类完成了 FTPS 显式模式功能的实现,一切正常。
我在使用 fileZilla > 3.0.11 作为客户端时遇到问题。我用谷歌搜索了一下,似乎sslstream
实现没有正确关闭连接。(不发送close_notify
警报)。使用 WinScp、SmartFTP 和 lftp 一切正常。
任何想法或任何其他 SSL 库?
或者也许某种方式来硬编码close_notify
警报并发送它?
具体的代码示例会很棒!
创建 sslStream:
_sslStream = new SslStream(socket.GetStream());
var _cert = new X509Certificate2(certPath,pass);
_sslStream.AuthenticateAsServer(_cert);
关闭连接:
_sslStream.Close();
socket.Close();
_sslStream = null;
socket = null;
FileZilla 3.6.0.2 错误日志:
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.