问题
I have used FluentFTP
lib im my project to work with FTP via TLS, but some trouble here.
This code working fine:
using (var conn = new FtpClient("adress", "user", "password"))
{
conn.EncryptionMode = FtpEncryptionMode.Explicit;
conn.ValidateAnyCertificate = true;
conn.Connect();
conn.CreateDirectory("/test/path/that/should/be/created", true);
}
And directory were created. But in other examples it not working good.
First exmple (logfile - https://pastebin.com/jNyZ3fmD):
public static void DownloadFile()
{
using (var conn = new FtpClient("adress", "user", "password"))
{
conn.EncryptionMode = FtpEncryptionMode.Explicit;
conn.ValidateAnyCertificate = true;
conn.Connect();
conn.DownloadFile("localPath", "ftpPath", FtpLocalExists.Overwrite, FtpVerify.Retry);
}
}
I have error:
"Error while uploading the file to the server. See InnerException for more info." IOException: Authentication failed because the remote party has closed the transport stream
Trying to get file/dir-list from FTP using code below return nothing in console (logfile - https://pastebin.com/V8AiLs8k):
using (var conn = new FtpClient("adress", "user", "password"))
{
//conn.Connect();
conn.EncryptionMode = FtpEncryptionMode.Explicit;
conn.ValidateCertificate += new FtpSslValidation(OnValidateCertificate);
conn.Connect();
// get a recursive listing of the files & folders in a specific folder
foreach (var item in conn.GetListing())
{
switch (item.Type)
{
case FtpFileSystemObjectType.Directory:
Console.WriteLine("Directory! " + item.FullName);
Console.WriteLine("Modified date: " + conn.GetModifiedTime(item.FullName));
break;
case FtpFileSystemObjectType.File:
Console.WriteLine("File! " + item.FullName);
Console.WriteLine("File size: " + conn.GetFileSize(item.FullName));
Console.WriteLine("Modified date: " + conn.GetModifiedTime(item.FullName));
Console.WriteLine("Chmod: " + conn.GetChmod(item.FullName));
break;
case FtpFileSystemObjectType.Link:
break;
}
Console.WriteLine(item);
}
}
The user has the privilege to download, create and delete files. But I can only make a dir on server.
回答1:
It seems to be due to a lack of TLS session resumption support in FluenFTP:
https://github.com/robinrodricks/FluentFTP/issues/347
If you confirm that with the server owner, you will have to switch to another FTP library.
For a similar question (for an implicit TLS, while you are using an explicit TLS) see:
Upload file to implicit FTPS server in C# with TLS session reuse
Or ask the owner to turn off session resumption requirement (though that's bad from a security point of view).
来源:https://stackoverflow.com/questions/61068219/authentication-failed-because-the-remote-party-has-closed-the-transport-stream