Hello,
Xojo newbie in here, i am having problems adding FTP Explicit Secure/TLS/SSL (AUTH TLS) support into https://github.com/charonn0/RB-FTP project FTP Server.
The project used a ServerSocket which has AddSocket event handler as below
Dim client As New FTP.Server
client.Banner = "Welcome to BSFTPd!"
client.AllowWrite = True
client.TimeOutPeriod = val(TimeOut.Text)
FTP.TimeOut = val(TimeOut.Text)
client.NetworkInterface = Me.NetworkInterface
AddHandler client.FTPLog, WeakAddressOf LogHandler
AddHandler client.Connected, WeakAddressOf enableFTPS 'Custom
AddHandler client.UserLogon, WeakAddressOf UserLogonHandler
Return client
enableFTPS method :
Sender.ConnectionType = SSLSocket.TLSv12
Dim certificate as FolderItem
certificate=GetFolderItem( "C:\\Users\ameless\\Documents\\server.key" )
If certificate <> Nil then
Sender.CertificateFile=certificate
Sender.CertificatePassword = ""
end if
If Sender.IsAuthTLS = True Then
Sender.Secure = True
ElseIf Sender.IsAuthTLS = False Then
Sender.Secure = False
End If
And Listening button Action event handler :
If FTPServer.IsListening Then
FTPServer.StopListening
Me.Caption = "Listen"
Else
Dim n As NetworkInterface
If nic.ListIndex <> -1 Then
n = nic.RowTag(nic.ListIndex)
Else
n = System.GetNetworkInterface(0)
End If
FTPServer.NetworkInterface = n
FTPServer.Port = Val(port.Text)
FTPServer.Listen()
Me.Caption = "Listening..."
End If
And a Do_Verb_AUTH method to handle “AUTH TLS” and “AUTH SSL”
If Argument = "TLS" or Argument.Trim = "" Then
Dim rand As New Random
Dim port As Integer = Rand.InRange(1024, 65534)
DoResponse(234, Banner)
Me.IsAuthTLS = True
End If
The question is the shared property which defined on FTP.Connection class, doesn’t get updated thorough the whole program session as true after the Do_Verb_AUTH being called, also when IsAuthTLS boolean check being disabled on enableFTPS method, i am getting “Socket error 0: Socket not connected.” from the RB-FTP server log, and hang from flashfxp ftp client.
Why the RB-FTP server doing these?, the RFC for the AUTH TLS/SSL available here . From reading the RFC, both parties, client and server should negotiate :
Establishing a Protected Session
Client Server
control data data control
====================================================================
socket()
bind()
socket()
connect() ----------------------------------------------> accept()
<---------------------------------------------- 220
AUTH TLS ---------------------------------------------->
<---------------------------------------------- 234
TLSneg() <----------------------------------------------> TLSneg()
PBSZ 0 ---------------------------------------------->
<---------------------------------------------- 200
PROT P ---------------------------------------------->
<---------------------------------------------- 200
USER fred ---------------------------------------------->
<---------------------------------------------- 331
PASS pass ---------------------------------------------->
<---------------------------------------------- 230