【发布时间】:2017-06-09 11:06:11
【问题描述】:
我正在通过TLS/SSL using the SslStream class 连接到 FTPS 服务器。一切都很顺利。但是我需要支持一个名为“CCC”的命令,它基本上会禁用加密。如果我只是这样做:
SendCommand("CCC");
sslStream.Close();
netStream.Write("...<futher FTP commands>...")
然后 FTP 服务器响应看似垃圾的数据(大约 30 个字节),然后再不响应任何命令(超时)。
FTP日志如下:
# Connect()
Status: Connecting to ***:21
Response: 220-IPv6 connections are also welcome on this server.
Command: AUTH TLS
Response: 234 AUTH TLS OK.
Status: FTPS Authentication Successful
Command: USER ***
Response: 331 User *** OK. Password required
Command: PASS ***
Response: 230 OK. Current restricted directory is /
Command: PBSZ 0
Response: 200 PBSZ=0
Command: PROT P
Response: 200 Data protection level set to "private"
Status: Text encoding: System.Text.UTF8Encoding
Command: OPTS UTF8 ON
Response: 200 OK, UTF-8 enabled
Command: SYST
Response: 215 UNIX Type: L8
Command: CCC
Response: 200 Control connection unencrypted
Status: The stale data was: ************
如您所见,FTP 服务器发回“200 Control connection unencrypted”,表示命令成功。同样重要的是要注意响应是以加密格式发送的。
所以我可能需要在禁用加密的同时继续使用 SslStream。在禁用加密算法时,可能仍需要“块模式”通信。有谁知道我该怎么做?
【问题讨论】:
-
我认为服务器可能希望您真正关闭安全连接,而不仅仅是丢弃它。据我所知,
SslStream不支持此功能,因此您可能需要研究如何手动执行此操作 -
“关闭安全连接”和丢弃它有什么区别?
标签: c# .net encryption ftp sslstream