加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 底层连接已关闭.服务器提交了协议违规

发布时间:2020-12-15 08:22:47 所属栏目:百科 来源:网络整理
导读:我试图使用以下代码获取FTPS FileZilla服务器的目录列表: ftpRequest = (FtpWebRequest)FtpWebRequest.Create(host + "/" + directory);ftpRequest.EnableSsl = true;ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateVali
我试图使用以下代码获取FTPS FileZilla服务器的目录列表:
ftpRequest = (FtpWebRequest)FtpWebRequest.Create(host + "/" + directory);
ftpRequest.EnableSsl = true;

ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateCertificate);
ftpRequest.Credentials = new NetworkCredential(user,pass);
ftpRequest.UseBinary = true;
ftpRequest.UsePassive = true;
ftpRequest.KeepAlive = true;
ftpRequest.Method = WebRequestMethods.Ftp.ListDirectory;
ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();

执行FtpWebResponse)ftpRequest.GetResponse()时出现异常:

the underlying connection was closed. The server committed a protocol
violation.

当我切换到正常的FTP连接.一切正常.

我错过了建立这个FTPS连接的东西吗?
感谢帮助

解决方法

FtpWebRequest类不支持隐式FTPS(参见 here).

当EnableSsl设置为true时,它实际上会向服务器触发AUTH TLS命令,要求启动显式FTPS会话.

在您的情况下,您必须配置Filezilla Server以使用显式FTPS.该程序记录于Filezilla Wiki

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读