“验证失败,因为远程方已关闭传输流"使用 FluentFTP 通过 TLS/SSL 向/从 FTP 服务器传输数据时 [英] "Authentication failed because the remote party has closed the transport stream" when transferring to/from FTP server over TLS/SSL using FluentFTP

查看:110
本文介绍了“验证失败,因为远程方已关闭传输流"使用 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 服务器传输数据时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆