【发布时间】:2014-10-09 12:45:02
【问题描述】:
我正在尝试使用以下代码获取 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() 执行时出现异常:
底层连接已关闭。服务器提交了一个协议 违规。
当我切换到正常的 FTP 连接时。一切正常。
我是否错过了建立此 FTPS 连接的内容? 感谢帮助
【问题讨论】:
-
您可以访问 Filezilla 服务器吗?你确定证书有效吗?您是否正确配置它以使用 explicit FTPS
-
是的,我可以访问服务器。证书也是有效的,并且检查了显式 FTPS。我使用的是指隐式 SSL/TLS 连接的端口 990。 FtpWebRequest 支持吗?
标签: c# ssl ftpwebrequest filezilla ftps