“由于远程方已关闭传输流,所以认证失败”。使用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

查看:950
本文介绍了“由于远程方已关闭传输流,所以认证失败”。使用FluentFTP在TLS / SSL上与FTP服务器进行双向传输时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目中使用了 FluentFTP lib im通过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);
}

已创建目录。

第一个示例(日志文件- 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,请参见:

使用TLS会话重用将文件上传到C#中的隐式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).

这篇关于“由于远程方已关闭传输流,所以认证失败”。使用FluentFTP在TLS / SSL上与FTP服务器进行双向传输时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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