FubarDevelopment / FtpServer

Portable FTP server written in .NET
http://fubardevelopment.github.io/FtpServer/
MIT License
482 stars 163 forks source link

Unrecognized command during establishing TLS connection #91

Open southz opened 4 years ago

southz commented 4 years ago

I've setup a FTP Server with explicit TLS settings. Sometimes (randomly) there are unrecognized command errors with the attached debug output. This error appears most frequently on the first connection after server startup. After connection timeout the next connection is established sucessfully.

Implementation of Certificate:

var cert = new X509Certificate2("localhost.pfx", "password");
            services.Configure<AuthTlsOptions>(cfg => {
                cfg.ServerCertificate = cert;
                cfg.ImplicitFtps = false;
            });

Debug Log:

NGettext: Creating a built-in plural rule for langcode "en" for locale "en". NGettext: Translation not found for message id "FTP Server Ready". info: FubarDev.FtpServer.FtpConnection[0] Connected from 127.0.0.1:65498 FubarDev.FtpServer.FtpConnection: Information: Connected from 127.0.0.1:65498 dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0] 220 FTP Server Ready FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler: Debug: 220 FTP Server Ready dbug: FubarDev.FtpServer.FtpConnection[0] AUTH TLS FubarDev.FtpServer.FtpConnection: Debug: AUTH TLS NGettext: Translation not found for message id "Enabling TLS Connection". dbug: FubarDev.FtpServer.ServerCommandHandlers.PauseConnectionServerCommandHandler[0] Receiver paused FubarDev.FtpServer.ServerCommandHandlers.PauseConnectionServerCommandHandler: Debug: Receiver paused dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0] 234 Enabling TLS Connection FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler: Debug: 234 Enabling TLS Connection dbug: FubarDev.FtpServer.FtpConnection[0] ????<4v;F??K???Pmk? 'rH?M?p4?S????0?,?(?$?? ?????????k?j?i?h?9?8?7?6?2?.?*?&?????=?5?/?+?'?#?? ?????????g?@???>?3?2?1?0?1?-?)?%?????<?/???? ????????? FubarDev.FtpServer.FtpConnection: Debug: NGettext: Translation not found for message id "Syntax error, command unrecognized.". dbug: FubarDev.FtpServer.FtpConnection[0] ? FubarDev.FtpServer.FtpConnection: Debug: ? NGettext: Translation not found for message id "Syntax error, command unrecognized.". dbug: FubarDev.FtpServer.FtpConnection[0] ?? ??E? ??? ??????????? FubarDev.FtpServer.FtpConnection: Debug: ?NGettext: Translation not found for message id "Syntax error, command unrecognized.".

fubar-coder commented 4 years ago

Which version do you use? It looks like the server received the TLS client authentication before it was able to stop the receiving process and thus tried to interpret the data as FTP command.

southz commented 4 years ago

I'm using Version 3.1.1 with .NET core 3.0.1

My Startup is basically like the example QuickStart.AspNetCoreHost but with custom implementations for Authentication (Database) and FileSystem (Mixed InMemory/Database).

Are there any further code examples or information i could provide to help?

EDIT: I tried the connections with WinSCP and FileZilla and this is happening on both and the first connection after Startup (of the FTP server) is commonly to fail. Following connection attempts seem to work in most cases.

southz commented 4 years ago

Hi, anything new on this bug?

fubar-coder commented 4 years ago

No, not yet, as I currently don't have much time and I'm not sure why this still happens (sometimes).