收到 421 错误
Getting a 421 error
我正在尝试从 public ftp 服务器下载文件。这是我的 C# 源代码:
FtpWebRequest request = FtpWebRequest.Create(new Uri("ftp://ftp.exotic-guild.de/test.exe")) as FtpWebRequest;
request.Credentials = new NetworkCredential("anonymous@exotic-guild.de", "");
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = true;
request.Method = WebRequestMethods.Ftp.DownloadFile;
FtpWebResponse response = request.GetResponse() as FtpWebResponse;
System.IO.Stream responseStream = response.GetResponseStream();
responseStream.Close();
response.Close(); //Closes the connection to the server
这是 public_ftp 服务器的文档链接:wolkenbauer anonymus ftp documentation。
使用 ftp.exe ftp.exotic-guild.de
响应是:
421 Sorry, cleartext sessions and weak ciphers are not accepted on this server.
Please reconnect using SSL/TLS security mechanisms.
Connection closed by remote host.
所以添加:
request.EnableSsl = true;
System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
第二行绕过证书验证,因为所提供的证书由于某种原因无效(您可能想调查一下)。
The remote certificate is invalid according to the validation procedure
我正在尝试从 public ftp 服务器下载文件。这是我的 C# 源代码:
FtpWebRequest request = FtpWebRequest.Create(new Uri("ftp://ftp.exotic-guild.de/test.exe")) as FtpWebRequest;
request.Credentials = new NetworkCredential("anonymous@exotic-guild.de", "");
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = true;
request.Method = WebRequestMethods.Ftp.DownloadFile;
FtpWebResponse response = request.GetResponse() as FtpWebResponse;
System.IO.Stream responseStream = response.GetResponseStream();
responseStream.Close();
response.Close(); //Closes the connection to the server
这是 public_ftp 服务器的文档链接:wolkenbauer anonymus ftp documentation。
使用 ftp.exe ftp.exotic-guild.de
响应是:
421 Sorry, cleartext sessions and weak ciphers are not accepted on this server. Please reconnect using SSL/TLS security mechanisms. Connection closed by remote host.
所以添加:
request.EnableSsl = true;
System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
第二行绕过证书验证,因为所提供的证书由于某种原因无效(您可能想调查一下)。
The remote certificate is invalid according to the validation procedure