Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "The TLS connection was non-properly terminated" #135

Open
ishimmings opened this issue Jul 13, 2022 · 2 comments
Open

Error "The TLS connection was non-properly terminated" #135

ishimmings opened this issue Jul 13, 2022 · 2 comments

Comments

@ishimmings
Copy link

I am using Windows 11. I have confirmed the certificate is correct by installing it and using it in a FTP site configured in IIS on my machine (disabled before running this).

With the following configuration:

var services = new ServiceCollection();
services.Configure<DotNetFileSystemOptions>(opt => opt.RootPath = @"C:\FTP");
services.AddFtpServer(builder => builder
                                 .UseDotNetFileSystem()
                                 .UseImplicitTls(new X509Certificate2(@"C:\localhost.pfx", "password"))
                                 .EnableAnonymousAuthentication());
services.Configure<FtpServerOptions>(opt =>
{
    opt.ServerAddress = "localhost";
    opt.Port = 990;
});
var serviceProvider = services.BuildServiceProvider();
var ftpServerHost = serviceProvider.GetRequiredService<IFtpServerHost>();
await ftpServerHost.StartAsync(CancellationToken.None).ConfigureAwait(false);

I get the following output using FileZilla:

Status:	Resolving address of localhost
Status:	Connecting to [::1]:990...
Status:	Connection established, initializing TLS...
Status:	TLS connection established, waiting for welcome message...
Error:	GnuTLS error -110 in gnutls_record_recv: The TLS connection was non-properly terminated.
Status:	Server did not properly shut down TLS connection
Error:	Could not read from socket: ECONNABORTED - Connection aborted
Error:	Could not connect to server

When trying to access in code using FluentFtp I get the error The connection was terminated before a greeting could be read. while connecting in the HandshakeAsync method with the following log output:

# ConnectAsync()
Status:   Connecting to ::1:990
Status:   FTPS Authentication Successful
Status:   Time to activate encryption: 0h 0m 0s.  Total Seconds: 0.0377264.

Any help greatly appreciated, thank you.

@fubar-coder
Copy link
Contributor

This is a (sadly) well-known GnuTLS bug, which interprets a "should" in the specification as a "must". The solution is to upgrade to .NET 6.0, which works better together with GnuTLS.

@sergshu
Copy link

sergshu commented Sep 5, 2022

I have created a .NET 6.0 project but the error still occurs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants