简体   繁体   English

具有WebClient错误的C#FTP:远程服务器返回错误:(534)534策略需要SSL

[英]C# FTP with WebClient Error: The remote server returned an error: (534) 534 Policy requires SSL

The purpose of my code is to upload some data to a FTP location. 我的代码的目的是将一些数据上传到FTP位置。

With my code I keep getting an error stating that the remote server requires SSL. 通过我的代码,我不断收到错误消息,指出远程服务器需要SSL。 I am using a .NET version greater then 4. All the other posts suggest I add the ServicePointManager code that I have below. 我使用的是大于4的.NET版本。所有其他帖子建议我添加下面的ServicePointManager代码。

The exception occurs on client.UploadData . 该异常发生在client.UploadData

Still no dice. 仍然没有骰子。 Any help would be very much appreciated. 任何帮助将不胜感激。

ServicePointManager.ServerCertificateValidationCallback +=
    (sender,certificate, chain, sslPolicyErrors) => true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
byte[] data = stream.ToArray(); //Data I want to upload to FTP location

using (WebClient client = new WebClient())
{
    client.Credentials = new NetworkCredential("*Username*", "*Password*");
    client.UploadData("ftp://file.example.com/Content/file", "STOR", data);
}

Afaik, WebClient does not support FTP over TLS (FTPS) natively (it actually does support it internally , but has no API to enable its use). Afaik, WebClient本身不支持TLS上的FTP(FTPS)(实际上内部支持,但没有API来启用它)。

Setting ServicePointManager.SecurityProtocol cannot help. 设置ServicePointManager.SecurityProtocol无法帮助。 And definitely do not set it to SecurityProtocolType.Ssl3 ! 绝对不要将其设置为SecurityProtocolType.Ssl3


声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C# FTP 与 FtpWebRequest 上传失败并显示“534 策略需要 ssl” - C# FTP with FtpWebRequest upload fails with “534 policy requires ssl” FluentFTP 和 TLS 连接到 IIS 失败,错误 534 - FluentFTP and TLS connection to IIS fails with error 534 WebClient - 远程服务器返回错误:(403)禁止 - WebClient - The remote server returned an error: (403) Forbidden FTP 远程服务器返回错误:(530) 未登录 - FTP The remote server returned an error: (530) Not logged in webclient远程服务器返回错误:(500)内部服务器错误 - webclient The remote server returned an error: (500) Internal Server Error 来自WebClient的错误:“远程服务器返回错误:(503)服务器不可用” - Error from WebClient: “The remote server returned an error: (503) Server Unavailable” FTP服务器使用ASP.NET C#返回500错误 - FTP server returned 500 error with ASP.NET C# WebClient引发异常远程服务器返回错误:(507)存储空间不足 - WebClient throw exception The remote server returned an error: (507) Insufficient Storage WebClient UploadFile远程服务器返回错误:(400)错误的请求 - WebClient UploadFile The remote server returned an error: (400) Bad Request WebClient:下载未完成:远程服务器返回错误:(403)禁止。 - WebClient : Download Not Complete: The remote server returned an error: (403) Forbidden.
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM