gpt4 book ai didi

c# - "Authentication failed because the remote party has closed the transport stream"使用 FluentFTP 通过 TLS/SSL 向/从 FTP 服务器传输时

转载 作者:行者123 更新时间:2023-12-04 22:36:16 28 4
gpt4 key购买 nike

我用过FluentFTP lib im 我的项目通过 TLS 使用 FTP,但这里有些麻烦。

此代码工作正常:

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);
}

并创建了目录。但在其他示例中,它无法正常工作。

第一个示例(日志文件 - 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);

}
}

我有错误:

"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



尝试使用以下代码从 FTP 获取文件/目录列表在控制台中不返回任何内容(日志文件 - 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);
}

}

用户有权下载、创建和删除文件。但我只能在服务器上创建一个目录。

最佳答案

这似乎是由于 FluenFTP 中缺乏 TLS session 恢复支持:
https://github.com/robinrodricks/FluentFTP/issues/347
如果您与服务器所有者确认,您将不得不切换到另一个 FTP 库。
对于类似的问题(对于隐式 TLS,当您使用显式 TLS 时),请参阅:
Upload file to implicit FTPS server in C# with TLS session reuse
或者要求所有者关闭 session 恢复要求(尽管从安全角度来看这很糟糕)。
有关该问题的更多引用,另请参阅 Can connect to FTP using FileZilla or WinSCP, but not with FtpWebRequest or FluentFTP .

关于c# - "Authentication failed because the remote party has closed the transport stream"使用 FluentFTP 通过 TLS/SSL 向/从 FTP 服务器传输时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61068219/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com