我试图使用以下代码获取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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。