【发布时间】:2017-12-28 09:12:08
【问题描述】:
我的以下代码在我的计算机上运行良好,无需代理。但是在客户端服务器中,他们需要向 FTP 客户端 (FileZilla) 添加代理才能访问 FTP。但是当我添加代理时它说
使用代理时无法启用 SSL。
FTP 代理
var proxyAddress = ConfigurationManager.AppSettings["ProxyAddress"];
WebProxy ftpProxy = null;
if (!string.IsNullOrEmpty(proxyAddress))
{
var proxyUserId = ConfigurationManager.AppSettings["ProxyUserId"];
var proxyPassword = ConfigurationManager.AppSettings["ProxyPassword"];
ftpProxy = new WebProxy
{
Address = new Uri(proxyAddress, UriKind.RelativeOrAbsolute),
Credentials = new NetworkCredential(proxyUserId, proxyPassword)
};
}
FTP 连接
var ftpRequest = (FtpWebRequest)WebRequest.Create(ftpAddress);
ftpRequest.Credentials = new NetworkCredential(
username.Normalize(),
password.Normalize()
);
ServicePointManager.ServerCertificateValidationCallback +=
(sender, cert, chain, sslPolicyErrors) => true;
ServicePointManager.Expect100Continue = false;
ftpRequest.Method = WebRequestMethods.Ftp.ListDirectory;
ftpRequest.EnableSsl = true;
//ftpRequest.Proxy = ftpProxy;
var response = (FtpWebResponse)ftpRequest.GetResponse();
【问题讨论】:
-
这是否与常规 ftp 客户端连接?
-
@Saruman 是的
标签: c# .net ftp ftpwebrequest ftps