Cindy Vuillaume
Cindy Vuillaume

Reputation: 21

Getting "This server requires encryption" when connecting to FTP server in C#

I want to upload a XML file on FTP via Code with unity, but i can't connect to the FTP first.

So before uploading I just try to access FTP and list directory.

I use this code:

FtpWebRequest request = (FtpWebRequest)WebRequest.Create(host);
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;

request.Credentials = new NetworkCredential(user, pass);

FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
Debug.Log(string.Format("Directory List Complete, status {0}", response.StatusDescription));

response.Close();

But I always have the same error :

Error : [Exception] Exception The authentication or decryption has failed.

Error : [Exception] Exception Server returned an error: 550-This server requires encryption. 550 You must issue the AUTH command to change to an encrypted session before you can attempt to login.

Looking for other post, I see that the authentication is Anonymous or mine is Normal.

Furthermore the FTP requires TLS protocol.

Thanks for helping me.

Upvotes: 2

Views: 1662

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202108

If your FTP server requires TLS/SSL encryption, you have to enable it using FtpWebRequest.EnableSsl:

request.EnableSsl = true;

Upvotes: 2

Related Questions