繁体   English   中英

尝试列出ftps服务器上的文件时,FluentFTP抛出“System.IO.IOException:Authentication failed”

[英]FluentFTP throws “System.IO.IOException: Authentication failed” when trying to list files on ftps server

说明使用FluentFTP连接到FileZilla FTPS服务器时,我们收到System.IO.IOException: Authentication failed because the remote party has closed the transport stream. 在尝试列出文件时。

我们可以建立初始连接,我们可以登录,但是当FluentFTP尝试通过EPSV建立数据连接时,它会因该异常而出错。

到目前为止,我们的研究似乎指向TLS恢复失败。 FTPS服务器坚持数据连接从控制连接恢复TLS会话,这似乎是失败的。 奇怪的是,这只发生在Linux或WSL上的dotnetcore上。 在Windows上的dotnetcore上一切正常。

版本 :DotNetCore 2.1.5 FluentFTP 19.2.2

OS Ubuntu 18.04 / Windows 10 WSL Ubuntu 18.04

演示代码

public async Task We_should_be_able_to_connect_and_list_files()
{
    var client = new FtpClient("myhost", "user", "pass");
    client.EncryptionMode = FtpEncryptionMode.Explicit;
    client.SslProtocols = SslProtocols.Tls;
    client.ValidateCertificate += (c, e) => { e.Accept = true; };

    await client.ConnectAsync();
    var items = await client.GetListingAsync("/");

    Assert.NotEmpty(items);
}

例外

System.IO.IOException : Authentication failed because the remote party has closed the transport stream.
   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
   at System.Net.Security.SslState.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
--- End of stack trace from previous location where exception was thrown ---
   at System.Net.Security.SslState.ThrowIfExceptional()
   at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
   at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)
   at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult)
   at System.Net.Security.SslStream.<>c.<AuthenticateAsClientAsync>b__46_2(IAsyncResult iar)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
   at FluentFTP.FtpSocketStream.ActivateEncryptionAsync(String targethost, X509CertificateCollection clientCerts, SslProtocols sslProtocols)
   at FluentFTP.FtpClient.OpenPassiveDataStreamAsync(FtpDataConnectionType type, String command, Int64 restart)
   at FluentFTP.FtpClient.OpenDataStreamAsync(String command, Int64 restart)
   at FluentFTP.FtpClient.GetListingAsync(String path, FtpListOption options)

FluentFTP日志

...

# GetListingAsync("/", Auto)
Command:  TYPE I
Response: 200 Type set to I

# OpenPassiveDataStreamAsync(AutoPassive, "MLSD /", 0)
Command:  EPSV
Response: 229 Entering Extended Passive Mode (|||50992|)
Status:   Connecting to ***:50992
Command:  MLSD /
Response: 150 Opening data channel for directory listing of "/"
Status:   Disposing FtpSocketStream...

我们做错了什么?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM