TLS 1.2 data connection not working with Pure FTPd
FTP OS: Windows
FTP Server: Pure-FTPd
**Computer OS:Windows 10 ?
FluentFTP Version: 34.4.1.0?
Hosting service implemented forced TLS 1.2 (jumpline). I can connect and login, but uploading a file always results in a 0 (zero) byte file. The file is 64 bytes and it looks like there is an issue with the data channel once the connection is made - but there is no response from the server and nothing useful in the log following the failed upload. Explicit TLS 1.2 works fine in filezilla and WinSCP however.
Logs :
# Connect()
Status: Connecting to ***:21
Response: 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
Response: 220-You are user number 3 of 50 allowed.
Response: 220-Local time is now 22:21. Server port: 21.
Response: 220-This is a private system - No anonymous login
Response: 220-IPv6 connections are also welcome on this server.
Response: 220 You will be disconnected after 15 minutes of inactivity.
Status: Detected FTP server: PureFTPd
Command: AUTH TLS
Response: 234 AUTH TLS OK.
Status: FTPS Authentication Successful
Status: Time to activate encryption: 0h 0m 0s. Total Seconds: 0.1900571.
Command: USER ***
Response: 331 User *** OK. Password required
Command: PASS ***
Response: 230 OK. Current restricted directory is /
Command: PBSZ 0
Response: 200 PBSZ=0
Command: PROT P
Response: 200 Data protection level set to "private"
Command: FEAT
Response: 211-Extensions supported:
Response: EPRT
Response: IDLE
Response: MDTM
Response: SIZE
Response: MFMT
Response: REST STREAM
Response: MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
Response: MLSD
Response: AUTH TLS
Response: PBSZ
Response: PROT
Response: UTF8
Response: TVFS
Response: ESTA
Response: PASV
Response: EPSV
Response: SPSV
Response: ESTP
Response: 211 End.
Status: Text encoding: System.Text.UTF8Encoding
Command: OPTS UTF8 ON
Response: 200 OK, UTF-8 enabled
Command: SYST
Response: 215 UNIX Type: L8
# DirectoryExists("severestudios")
# GetWorkingDirectory()
Command: PWD
Response: 257 "/" is your current location
Command: CWD severestudios
Response: 250 OK. Current directory is /severestudios
Command: CWD /
Response: 250 OK. Current directory is /
# SetWorkingDirectory("severestudios")
Command: CWD severestudios
Response: 250 OK. Current directory is /severestudios
# UploadFile("C:\Users\Dan Desjardins\AppData\Local\Temp\tmp7CD9.tmp", "tmp7CD9.tmp", Overwrite, False, None)
# FileExists("tmp7CD9.tmp")
# GetWorkingDirectory()
Command: PWD
Response: 257 "/severestudios" is your current location
Command: SIZE /severestudios/tmp7CD9.tmp
Response: 550 Can't check for file existence
# OpenWrite("tmp7CD9.tmp", Binary)
Command: TYPE I
Response: 200 TYPE is now 8-bit binary
# OpenPassiveDataStream(EPSV, "STOR tmp7CD9.tmp", 0)
Command: EPSV
Response: 229 Extended Passive mode OK (|||42418|)
Status: Connecting to ***:42418
Command: STOR tmp7CD9.tmp
Response: 150 Accepted data connection
Status: FTPS Authentication Successful
Status: Time to activate encryption: 0h 0m 0s. Total Seconds: 0.2208748.
Status: Disposing FtpSocketStream...
# FileExists("severestudios/tmp7CD9.tmp")
# GetWorkingDirectory()
Command: PWD
Status: Testing connectivity using Socket.Poll()...
Status: Disposing FtpSocketStream...
# Dispose()
Status: Disposing FtpClient object...
Status: Disposing FtpSocketStream...
My Code
` Public Function TestFluentFTP(ByRef Response As String) As Boolean
flFTP = New FluentFTP.FtpClient()
flFTP.EncryptionMode = FluentFTP.FtpEncryptionMode.Explicit
flFTP.DataConnectionEncryption = True
flFTP.DownloadDataType = FluentFTP.FtpDataType.Binary
flFTP.UploadDataType = FluentFTP.FtpDataType.Binary
flFTP.ValidateAnyCertificate = True
flFTP.DataConnectionType = FluentFTP.FtpDataConnectionType.EPSV
flFTP.SslProtocols = Security.Authentication.SslProtocols.Tls12
flFTP.Host = FTPHost
flFTP.Credentials = New Net.NetworkCredential(Me.FTPUsername, Me.FTPPassword)
flFTP.Port = FTPPort
AddHandler flFTP.ValidateCertificate, New FluentFTP.FtpSslValidation(AddressOf OnValidateflCertificate)
Dim LocalUploadFile As New FileInfo(Path.GetTempFileName)
Dim RemoteUploadFile As New String(LocalUploadFile.Name)
Dim bIsConnectedForFinally As Boolean = False 'can't use the kFTP.Isconnecteed property in finally as it appears to return true after a failed connection attempt
My.Computer.FileSystem.WriteAllText(LocalUploadFile.FullName, "testtext", False)
'logging
FluentFTP.FtpTrace.AddListener(New TextWriterTraceListener("d:\flftp.log"))
FluentFTP.FtpTrace.LogUserName = False
FluentFTP.FtpTrace.LogPassword = False
FluentFTP.FtpTrace.LogIP = False
Try
flFTP.Connect()
If flFTP.IsConnected Then
If LocalUploadFile.Exists Then
bIsConnectedForFinally = True
If Not flFTP.DirectoryExists(Me.FTPFolder) Then
flFTP.CreateDirectory(Me.FTPFolder)
flFTP.SetWorkingDirectory(Me.FTPFolder)
Else
flFTP.SetWorkingDirectory(Me.FTPFolder)
End If
flFTP.UploadFile(LocalUploadFile.FullName, RemoteUploadFile)
If flFTP.FileExists(FTPFolder & "/" & RemoteUploadFile) Then
Me.LastFTPError = "ok"
Return True
Else
Me.LastFTPError = "upload file not found after succesful upload"
Return False
End If
Else
Me.LastFTPError = "local file missing"
Return False
End If
Else
Me.LastFTPError = "FTP Did not connect!"
Return False
End If
Catch ex As Exception
Me.LastFTPError = ex.Message
Response = flFTP.LastReply.Message
bIsConnectedForFinally = False
Return False
Finally
Try
If bIsConnectedForFinally Then
If flFTP.FileExists(RemoteUploadFile) Then
flFTP.DeleteFile(RemoteUploadFile)
End If
End If
Catch ex As Exception
'don't care
End Try
flFTP.Disconnect()
flFTP.Dispose()
If LocalUploadFile.Exists Then
LocalUploadFile.Delete()
End If
End Try
End Function
Can you paste the filezilla logs?
Will do. I need to set up a separate machine again due to both Eset and Windows defender flagging filezilla. They've had this problem since 2018 and apparently haven't seen fit to fix it.
Hi having the same issue at the moment. The connection just seems to dump before file transfer.
my very simple code; ` Using ftp = New FtpClient(ftpHost, ftpusername, ftppassword)
ftp.EncryptionMode = FtpEncryptionMode.Explicit
ftp.ValidateAnyCertificate = True
ftp.Connect()
' upload a file to an existing FTP directory)
ftp.UploadFile(filetoupload, FileName) 'FtpRemoteExists.Overwrite, FtpVerify.Retry
End Using`
OutputWindow:
Connect()
Status: Connecting to 85.XXXXXX:21
Response: 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
Response: 220-You are user number 2 of 50 allowed.
Response: 220-Local time is now 11:06. Server port: 21.
Response: 220-This is a private system - No anonymous login
Response: 220-IPv6 connections are also welcome on this server.
Response: 220 You will be disconnected after 15 minutes of inactivity.
Status: Detected FTP server: PureFTPd
Command: AUTH TLS
Response: 234 AUTH TLS OK.
Status: FTPS Authentication Successful
Status: Time to activate encryption: 0h 0m 0s. Total Seconds: 0.1471586.
Command: USER maxXXXXX.com
Response: 331 User maXXXXX.com OK. Password required
Command: PASS ***
Response: 230 OK. Current restricted directory is /
Command: PBSZ 0
Response: 200 PBSZ=0
Command: PROT P
Response: 200 Data protection level set to "private"
Command: FEAT
Response: 211-Extensions supported:
Response: EPRT
Response: IDLE
Response: MDTM
Response: SIZE
Response: MFMT
Response: REST STREAM
Response: MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
Response: MLSD
Response: AUTH TLS
Response: PBSZ
Response: PROT
Response: UTF8
Response: TVFS
Response: ESTA
Response: PASV
Response: EPSV
Response: SPSV
Response: ESTP
Response: 211 End.
Status: Text encoding: System.Text.UTF8Encoding
Command: OPTS UTF8 ON
Response: 200 OK, UTF-8 enabled
Command: SYST
Response: 215 UNIX Type: L8
UploadFile("C:\MAXXXXXXXXdate.csv", "StoXXXXate.csv", Overwrite, False, None)
FileExists("StoXXXXXate.csv")
GetWorkingDirectory()
Command: PWD
Response: 257 "/" is your current location
Command: SIZE /StockToUpdate.csv
Response: 213 17
DeleteFile("StoXXXXXte.csv")
Command: DELE StockToUpdate.csv
Response: 250 Deleted StockToUpdate.csv
OpenWrite("StoXXXXXdate.csv", Binary)
Command: TYPE I
Response: 200 TYPE is now 8-bit binary
OpenPassiveDataStream(AutoPassive, "STOR StockToUpdate.csv", 0)
Command: EPSV
Response: 229 Extended Passive mode OK (|||37965|)
Status: Connecting to 85.XXXXXX1:37965
Command: STOR StockToUpdate.csv
Response: 150 Accepted data connection
Status: FTPS Authentication Successful
Status: Time to activate encryption: 0h 0m 0s. Total Seconds: 0.1159728.
Status: Disposing FtpSocketStream...`
Dispose()
Status: Disposing FtpClient object...
Status: Testing connectivity using Socket.Poll()...
Status: Disposing FtpSocketStream...
Status: Disposing FtpSocketStream...
FileZilla log:
Status: Connecting to 85.XXXXXXXX:21...
Status: Connection established, waiting for welcome message...
Status: Initializing TLS...
Status: Verifying certificate...
Status: TLS connection established.
Status: Logged in
Status: Retrieving directory listing of "/"...
Status: Directory listing of "/" successful
Status: Deleting "/StoXXXXXXte.csv"
Status: Resolving address of webXXXXXXXXXXX.net.uk
Status: Connecting to 85.XXXXXX1:21...
Status: Connection established, waiting for welcome message...
Status: Initializing TLS...
Status: Verifying certificate...
Status: TLS connection established.
Status: Logged in
Status: Starting upload of C:\maxXXXXXXXXXXdate.csv
Status: File transfer successful, transferred 17 bytes in 1 second
Status: Retrieving directory listing of "/"...
Status: Directory listing of "/" successful
I have the same issue on my side on September 2020. HEre my FileZilla Log with the command send.
FileZilla :
Response: 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
Response: 220-You are user number 5 of 500 allowed.
Response: 220-Local time is now 19:14. Server port: 21.
Response: 220-This is a private system - No anonymous login
Response: 220 You will be disconnected after 15 minutes of inactivity.
Command: AUTH TLS
Response: 234 AUTH TLS OK.
Status: Initializing TLS...
Status: Verifying certificate...
Status: TLS connection established.
Command: USER**************
Response: 331 User ************** OK. Password required
Command: PASS **************
Response: 230-Your bandwidth usage is restricted
Response: 230 OK. Current restricted directory is /
Command: OPTS UTF8 ON
Response: 200 OK, UTF-8 enabled
Command: PBSZ 0
Response: 200 PBSZ=0
Command: PROT P
Response: 200 Data protection level set to "private"
Status: Logged in
Status: Starting upload of D:\Test.Test
Command: CWD /public_html/folder
Response: 250 OK. Current directory is /public_html/folder
Command: TYPE I
Response: 200 TYPE is now 8-bit binary
Command: PASV
Response: 227 Entering Passive Mode (*************)
Command: STOR Test.Test
Response: 150 Accepted data connection
Response: 226-File successfully transferred
Response: 226 0.214 seconds (measured here), 444.32 Kbytes per second
Status: File transfer successful, transferred 97,408 bytes in 1 second
Status: Retrieving directory listing of "/public_html/folder"...
Command: PASV
Response: 227 Entering Passive Mode (*************)
Command: MLSD
Response: 150 Accepted data connection
Response: 226-Options: -a -l
Response: 226 3 matches total
Status: Directory listing of "/public_html/folder" successful
FluentFTP
# OpenWrite("/public_html/Test.Test", Binary)
Command: TYPE I
Response: 200 TYPE is now 8-bit binary
# OpenPassiveDataStream(AutoPassive, "STOR /public_html/Test.Test", 0)
Command: EPSV
Response: 229 Extended Passive mode OK (|||*****|)
Status: Connecting to *************
Command: STOR /public_html/Test.Test
Response: 150 Accepted data connection
Status: FTPS Authentication Successful
Status: Time to activate encryption: 0h 0m 0s. Total Seconds: 0.0669612.
Status: Disposing FtpSocketStream...
# OpenAppend("/public_html/Test.Test", Binary)
# GetFileSize("/public_html/Test.Test")
Command: SIZE /public_html/Test.Test
Status: Disposing FtpSocketStream...
Exception thrown: 'FluentFTP.FtpException' in FluentFTP.dll
The difference for me is FileZilla is sending an PASV command while FluentFTP is sending an EPSV and maybe trying to reconnect again?
This issue is totally stale and refers to ancient FluentFTP versions. If any of the users involved are still experiencing an issue they should feel free to open a new issue, based on a more current version of FluentFTP. The current version, among many other improvements, produces more logging information to diagnose problems like the ones described above.
Looks like this can be closed due to no activity with a more current FluentFPT version and log.