You are testing it with a non-trusted certificate, right? You should test it with the accept all CustomTrustManager.
Yes you are correct, I am testing with untrusted self signed cert..
here is my updated code:
Sub Class_Globals
Private fx As JFX
Private ftp As FTP
Private sftp As SFtp
Private ctm As CustomTrustManager
Private ftpUser As String
Private ftpUserPswd As String
Private ftpHost As String
Private ftpPort As Int
Private ftpPassive As Boolean
Private ftpFolder As String
Private ftpSSLimplicit As Boolean
Private ftpSSLexplicit As Boolean
'ftp
' C = Clear P=Protected
Private sPROT_Action As String
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(Host As String, User As String, Password As String, _
port As Int, PassiveMode As Boolean, folder As String, Encryption As String)
ftpHost = Host
ftpUser = User
ftpUserPswd = Password
ftpPort = port
ftpPassive = PassiveMode
ftpFolder = folder
If Encryption = "SSL - Implicit" Then
ftpSSLimplicit = True
ftpSSLexplicit = False
sPROT_Action = "P"
Else if Encryption = "SSL - Explicit" Then
ftpSSLimplicit = False
ftpSSLexplicit = True
sPROT_Action = "P"
Else
ftpSSLimplicit = False
ftpSSLexplicit = False
sPROT_Action = "C"
End If
ctm.InitializeAcceptAll
ftp.SetCustomSSLTrustManager(ctm)
End Sub
Public Sub SendFileTest(FileandPath As String)
Dim sPath As String = File.GetFileParent(FileandPath)
Dim sFile As String = File.GetName(FileandPath)
ftp.Initialize("FTPTest", ftpHost, ftpPort, ftpUser, ftpUserPswd)
ftp.PassiveMode = ftpPassive
ftp.UseSSL = ftpSSLimplicit
ftp.UseSSLExplicit = ftpSSLexplicit
ftp.SendCommand("PROT", sPROT_Action)
'ftp.SendCommand("PBSZ", "0")
ftp.UploadFile(sPath, sFile, False, ftpFolder & sFile)
End Sub
error in Explicit mode:
javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:992)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:767)
at org.apache.commons.net.ftp.FTPClient.__storeFile(FTPClient.java:557)
at org.apache.commons.net.ftp.FTPClient.storeFile(FTPClient.java:1716)
at anywheresoftware.b4a.net.FTPWrapper$2.run(FTPWrapper.java:239)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.EOFException: SSL peer shut down incorrectly
at sun.security.ssl.InputRecord.read(InputRecord.java:505)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973)
... 12 more
error in implicit mode:
Waiting for debugger to connect...
Program started.
java.lang.RuntimeException: Error uploading file.
450 Unknown TLS error on data connection
at anywheresoftware.b4a.net.FTPWrapper$2.run(FTPWrapper.java:241)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
read out from fpt server:
(000010)3/8/2020 16:13:59 PM - (not logged in) (192.168.1.104)> Connected on port 21, sending welcome message...
(000010)3/8/2020 16:13:59 PM - (not logged in) (192.168.1.104)> 220-FileZilla Server 0.9.60 beta
(000010)3/8/2020 16:13:59 PM - (not logged in) (192.168.1.104)> 220-written by Tim Kosse (
tim.kosse@filezilla-project.org)
(000010)3/8/2020 16:13:59 PM - (not logged in) (192.168.1.104)> 220 Please visit
https://filezilla-project.org/
(000010)3/8/2020 16:13:59 PM - (not logged in) (192.168.1.104)> AUTH TLS
(000010)3/8/2020 16:13:59 PM - (not logged in) (192.168.1.104)> 234 Using authentication type TLS
(000010)3/8/2020 16:13:59 PM - (not logged in) (192.168.1.104)> TLS connection established
(000010)3/8/2020 16:13:59 PM - (not logged in) (192.168.1.104)> USER TestT
(000010)3/8/2020 16:13:59 PM - (not logged in) (192.168.1.104)> 331 Password required for testt
(000010)3/8/2020 16:13:59 PM - (not logged in) (192.168.1.104)> PASS *******
(000010)3/8/2020 16:13:59 PM - testt (192.168.1.104)> 230 Logged on
(000010)3/8/2020 16:13:59 PM - testt (192.168.1.104)> PBSZ 0
(000010)3/8/2020 16:13:59 PM - testt (192.168.1.104)> 200 PBSZ=0
(000010)3/8/2020 16:13:59 PM - testt (192.168.1.104)> PROT P
(000010)3/8/2020 16:13:59 PM - testt (192.168.1.104)> 200 Protection level set to P
(000010)3/8/2020 16:13:59 PM - testt (192.168.1.104)> PROT P
(000010)3/8/2020 16:13:59 PM - testt (192.168.1.104)> 200 Protection level set to P
(000010)3/8/2020 16:13:59 PM - testt (192.168.1.104)> TYPE I
(000010)3/8/2020 16:13:59 PM - testt (192.168.1.104)> 200 Type set to I
(000010)3/8/2020 16:13:59 PM - testt (192.168.1.104)> PORT 192,168,1,104,42,82
(000010)3/8/2020 16:13:59 PM - testt (192.168.1.104)> 200 Port command successful
(000010)3/8/2020 16:13:59 PM - testt (192.168.1.104)> STOR Test/Test_FTP_Upload.txt
(000010)3/8/2020 16:13:59 PM - testt (192.168.1.104)> 150 Opening data channel for file upload to server of "/Test/Test_FTP_Upload.txt"
(000010)3/8/2020 16:14:00 PM - testt (192.168.1.104)> 450 TLS session of data connection has not resumed or the session does not match the control connection
(000010)3/8/2020 16:14:00 PM - testt (192.168.1.104)> disconnected.
(000012)3/8/2020 16:19:47 PM - (not logged in) (192.168.1.104)> Connected on port 32, sending welcome message...
(000012)3/8/2020 16:19:47 PM - (not logged in) (192.168.1.104)> 220-FileZilla Server 0.9.60 beta
(000012)3/8/2020 16:19:47 PM - (not logged in) (192.168.1.104)> 220-written by Tim Kosse (
tim.kosse@filezilla-project.org)
(000012)3/8/2020 16:19:47 PM - (not logged in) (192.168.1.104)> 220 Please visit
https://filezilla-project.org/
(000012)3/8/2020 16:19:48 PM - (not logged in) (192.168.1.104)> TLS connection established
(000012)3/8/2020 16:19:48 PM - (not logged in) (192.168.1.104)> USER TestT
(000012)3/8/2020 16:19:48 PM - (not logged in) (192.168.1.104)> 331 Password required for testt
(000012)3/8/2020 16:19:48 PM - (not logged in) (192.168.1.104)> PASS *******
(000012)3/8/2020 16:19:48 PM - testt (192.168.1.104)> 230 Logged on
(000012)3/8/2020 16:19:48 PM - testt (192.168.1.104)> PROT P
(000012)3/8/2020 16:19:48 PM - testt (192.168.1.104)> 200 Protection level set to P
(000012)3/8/2020 16:19:48 PM - testt (192.168.1.104)> TYPE I
(000012)3/8/2020 16:19:48 PM - testt (192.168.1.104)> 200 Type set to I
(000012)3/8/2020 16:19:48 PM - testt (192.168.1.104)> PORT 192,168,1,104,42,119
(000012)3/8/2020 16:19:48 PM - testt (192.168.1.104)> 200 Port command successful
(000012)3/8/2020 16:19:48 PM - testt (192.168.1.104)> STOR Test/Test_FTP_Upload.txt
(000012)3/8/2020 16:19:48 PM - testt (192.168.1.104)> 150 Opening data channel for file upload to server of "/Test/Test_FTP_Upload.txt"
(000012)3/8/2020 16:19:48 PM - testt (192.168.1.104)> Data connection TLS warning: SSL_accept: error 1 in SSLv2/v3 read client hello A
(000012)3/8/2020 16:19:48 PM - testt (192.168.1.104)> 450 Unknown TLS error on data connection
(000012)3/8/2020 16:19:48 PM - testt (192.168.1.104)> disconnected.