quot;Authentication failed because the remote party has closed the transport streamquot; when transferring to/from FTP server over TLS/SSL using FluentFTP(“验证失败,因为远程方已关闭传输流使用 FluentFTP 通过 TLS/SSL 向/从 FTP 服务器传输数据时)
问题描述
我在我的项目中使用 FluentFTP
lib 来通过 TLS 使用 FTP,但这里有些麻烦.
I have used FluentFTP
lib im my project to work with FTP via TLS, but some trouble here.
这段代码运行良好:
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.
第一个示例(日志文件 - https://pastebin.com/jNyZ3fmD):
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);
}
}
我有错误:
"将文件上传到服务器时出错.请参阅 InnerException 了解更多信息."IOException:身份验证失败,因为远程方已关闭传输流
"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):
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.
推荐答案
好像是因为 FluenFTP 缺少 TLS 会话恢复支持:
https://github.com/robinrodricks/FluentFTP/issues/347
It seems to be due to a lack of TLS session resumption support in FluenFTP:
https://github.com/robinrodricks/FluentFTP/issues/347
如果您与服务器所有者确认,您将不得不切换到另一个 FTP 库.对于类似的问题(对于隐式 TLS,当您使用显式 TLS 时)请参阅:
在 C# 中使用 TLS 会话重用将文件上传到隐式 FTPS 服务器
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).
有关该问题的更多参考,另请参阅可以使用 FileZilla 或 WinSCP 连接到 FTP,但不能使用 FtpWebRequest 或 FluentFTP.
For more references about the problem, see also Can connect to FTP using FileZilla or WinSCP, but not with FtpWebRequest or FluentFTP.
这篇关于“验证失败,因为远程方已关闭传输流"使用 FluentFTP 通过 TLS/SSL 向/从 FTP 服务器传输数据时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:“验证失败,因为远程方已关闭传输流"使用
基础教程推荐
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01