我正在尝试基于 EventMachine 编写一个简单的 FTPS 服务器。
控制插座正常工作。使用数据套接字进行数据传输时,似乎一切正常(TLS 握手成功完成并接收到数据),但随后我收到一条错误消息。这是我在 Filezilla 中得到的:
Command: LIST
Response: 150 Opening ASCII mode data connection for file list
Trace: CFtpControlSocket::TransferParseResponse()
Trace: code = 1
Trace: state = 4
Trace: CFtpControlSocket::SendNextCommand()
Trace: CFtpControlSocket::TransferSend()
Trace: state = 5
Trace: CTransferSocket::OnConnect
Trace: CTlsSocket::Handshake()
Trace: gnutls_session_get_data on primary socket failed: -51
Trace: CTlsSocket::ContinueHandshake()
Trace: CTlsSocket::OnSend()
Trace: CTlsSocket::OnSend()
Trace: CTlsSocket::OnRead()
Trace: CTlsSocket::ContinueHandshake()
Trace: CTlsSocket::OnRead()
Trace: CTlsSocket::ContinueHandshake()
Trace: Handshake successful
Trace: Cipher: AES-256-CBC, MAC: SHA1
Trace: CTlsSocket::OnRead()
Trace: CTransferSocket::OnConnect
Trace: CTransferSocket::OnReceive(), m_transferMode=0
Listing: -rwxrwxrwx 1 owner group 1011 Dec 12 23:05 a.tmp
Trace: CTlsSocket::Failure(-9, 0)
Error: GnuTLS error -9: A TLS packet with unexpected length was received.
Status: Server did not properly shut down TLS connection
Error: Could not read from transfer socket: ECONNABORTED - Connection aborted
Trace: CTransferSocket::TransferEnd(3)
Trace: CFtpControlSocket::OnReceive()
Response: 226 Closing data connection, sent 70 bytes
Trace: CFtpControlSocket::TransferParseResponse()
Trace: code = 2
Trace: state = 5
Trace: CFtpControlSocket::SendNextCommand()
Trace: CFtpControlSocket::TransferSend()
Trace: state = 8
Trace: CFtpControlSocket::TransferEnd()
Trace: CFtpControlSocket::ResetOperation(2)
Trace: CControlSocket::ResetOperation(2)
Trace: CFtpControlSocket::ParseSubcommandResult(2)
Trace: CFtpControlSocket::ListSubcommandResult()
Trace: state = 3
Trace: CFtpControlSocket::ResetOperation(2)
Trace: CControlSocket::ResetOperation(2)
Error: Failed to retrieve directory listing
Trace: CFileZillaEnginePrivate::ResetOperation(2)
ftp-ssl 也会发出错误,尽管有些不同
--> LIST
150 Opening ASCII mode data connection for file list
===>START SSL connect on DATA
ftp: SSL_connect DATA error 0 - error:00000000:lib(0):func(0):reason(0)
226 Closing data connection, sent 70 bytes
421 Service not available, remote server has closed connection
从我在网上发现的情况来看,我怀疑这种行为是因为 close_notify 在连接结束时没有发出?如果是这样,是否有任何已知的基于 Ruby 的解决方案(例如使用 OpenSSL::SSL::SSLSocket)?