FluentFTP throws “System.IO.IOException: Authentication failed” when trying to list files on ftps server
Description
When connecting to a FileZilla FTPS server with FluentFTP, we get a System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
when trying to list files.
We can establish the initial connection, we can log in, but when FluentFTP tries to establish the data connection via EPSV, it errors out with that exception.
Our research so far seems to point towards the TLS resumption failing. FTPS servers insist on the data connection resuming the TLS session from the control connection, and that seems to be failing. Curiously, this only occurs on dotnetcore on Linux or WSL. Everything works fine on dotnetcore on Windows.
Versions:
DotNetCore 2.1.5
FluentFTP 19.2.2
OS
Ubuntu 18.04 /
Windows 10 WSL Ubuntu 18.04
Demo Code
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);
}
Exception
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 Log
...
# 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...
What are we doing wrong?
c# .net-core windows-subsystem-for-linux ftps fluentftp
add a comment |
Description
When connecting to a FileZilla FTPS server with FluentFTP, we get a System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
when trying to list files.
We can establish the initial connection, we can log in, but when FluentFTP tries to establish the data connection via EPSV, it errors out with that exception.
Our research so far seems to point towards the TLS resumption failing. FTPS servers insist on the data connection resuming the TLS session from the control connection, and that seems to be failing. Curiously, this only occurs on dotnetcore on Linux or WSL. Everything works fine on dotnetcore on Windows.
Versions:
DotNetCore 2.1.5
FluentFTP 19.2.2
OS
Ubuntu 18.04 /
Windows 10 WSL Ubuntu 18.04
Demo Code
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);
}
Exception
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 Log
...
# 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...
What are we doing wrong?
c# .net-core windows-subsystem-for-linux ftps fluentftp
1
After some additional testing, I think it's a bug in FluentFTP: github.com/robinrodricks/FluentFTP/issues/347
– Christoph Lütjen
Nov 14 '18 at 21:45
add a comment |
Description
When connecting to a FileZilla FTPS server with FluentFTP, we get a System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
when trying to list files.
We can establish the initial connection, we can log in, but when FluentFTP tries to establish the data connection via EPSV, it errors out with that exception.
Our research so far seems to point towards the TLS resumption failing. FTPS servers insist on the data connection resuming the TLS session from the control connection, and that seems to be failing. Curiously, this only occurs on dotnetcore on Linux or WSL. Everything works fine on dotnetcore on Windows.
Versions:
DotNetCore 2.1.5
FluentFTP 19.2.2
OS
Ubuntu 18.04 /
Windows 10 WSL Ubuntu 18.04
Demo Code
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);
}
Exception
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 Log
...
# 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...
What are we doing wrong?
c# .net-core windows-subsystem-for-linux ftps fluentftp
Description
When connecting to a FileZilla FTPS server with FluentFTP, we get a System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
when trying to list files.
We can establish the initial connection, we can log in, but when FluentFTP tries to establish the data connection via EPSV, it errors out with that exception.
Our research so far seems to point towards the TLS resumption failing. FTPS servers insist on the data connection resuming the TLS session from the control connection, and that seems to be failing. Curiously, this only occurs on dotnetcore on Linux or WSL. Everything works fine on dotnetcore on Windows.
Versions:
DotNetCore 2.1.5
FluentFTP 19.2.2
OS
Ubuntu 18.04 /
Windows 10 WSL Ubuntu 18.04
Demo Code
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);
}
Exception
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 Log
...
# 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...
What are we doing wrong?
c# .net-core windows-subsystem-for-linux ftps fluentftp
c# .net-core windows-subsystem-for-linux ftps fluentftp
edited Nov 14 '18 at 17:56
Christoph Lütjen
1,374811
1,374811
asked Nov 14 '18 at 17:36
adhominemadhominem
817619
817619
1
After some additional testing, I think it's a bug in FluentFTP: github.com/robinrodricks/FluentFTP/issues/347
– Christoph Lütjen
Nov 14 '18 at 21:45
add a comment |
1
After some additional testing, I think it's a bug in FluentFTP: github.com/robinrodricks/FluentFTP/issues/347
– Christoph Lütjen
Nov 14 '18 at 21:45
1
1
After some additional testing, I think it's a bug in FluentFTP: github.com/robinrodricks/FluentFTP/issues/347
– Christoph Lütjen
Nov 14 '18 at 21:45
After some additional testing, I think it's a bug in FluentFTP: github.com/robinrodricks/FluentFTP/issues/347
– Christoph Lütjen
Nov 14 '18 at 21:45
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53305884%2ffluentftp-throws-system-io-ioexception-authentication-failed-when-trying-to-l%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53305884%2ffluentftp-throws-system-io-ioexception-authentication-failed-when-trying-to-l%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
After some additional testing, I think it's a bug in FluentFTP: github.com/robinrodricks/FluentFTP/issues/347
– Christoph Lütjen
Nov 14 '18 at 21:45