C# &引用;身份验证失败,因为远程方已关闭传输流;使用FluentFTP通过TLS/SSL与FTP服务器进行传输时

C# &引用;身份验证失败,因为远程方已关闭传输流;使用FluentFTP通过TLS/SSL与FTP服务器进行传输时,c#,.net,ssl,ftp,fluentftp,C#,.net,Ssl,Ftp,Fluentftp,我已经使用FluentFTPlib-im-my-project通过TLS使用FTP,但这里有些麻烦 此代码运行良好: using (var conn = new FtpClient("adress", "user", "password")) { conn.EncryptionMode = FtpEncryptionMode.Explicit; conn.ValidateAnyCertificate = true; conn.Connect(); conn.Cr

我已经使用
FluentFTP
lib-im-my-project通过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);
}
和目录已创建。但在其他例子中,它的效果并不好

第一个示例(日志文件-):

我有一个错误:

“将文件上载到服务器时出错。有关详细信息,请参阅InnerException。” 更多信息。” IOException:身份验证失败,因为远程 党已经关闭了交通流

尝试使用下面的代码从FTP获取文件/目录列表时,在控制台(日志文件-)中不返回任何内容:


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

这似乎是因为FluenFTP中缺少TLS会话恢复支持:

如果您与服务器所有者确认,则必须切换到另一个FTP库。 有关类似的问题(对于隐式TLS,使用显式TLS时),请参见:

或者要求所有者关闭会话恢复要求(尽管从安全角度看这很糟糕)

有关此问题的更多参考资料,请参见

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

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

}