Hello
I have been trying to connect to a ftp site that uses TSL/SSL security.
After trying to use the native libraries in .net i discovered that they did not support ftps through a proxy, and after searching online i came upon the Rebex libraries which several people on different sites claimed could connect too a ftps site through a proxy.
I have been trying for a week now with little success and i am hoping that someone on this board could help me.
The code i am using is this
TlsParameters tls = new TlsParameters();
tls.CertificateVerifier = CertificateVerifier.AcceptAll;
Ftp client = new Ftp();
client.LogWriter = new Rebex.FileLogWriter(@"C:\temp\rebex.log");
client.LogWriter.Level = Rebex.LogLevel.Verbose;
client.Proxy = new FtpProxy(FtpProxyType.HttpConnect,ProxyAdress,ProxyPort);
client.Connect(FTPS_adress, FTPS_port, tls, FtpSecurity.Explicit);
client.Secure(tls);
client.Login(usernam, password);
FtpResponse resp = client.ReadResponse();
"Do something"
client.Disconnect();
Regarding the bad code structure, right now i am desperately trying to get a successful a connection so i don't care about it.
When i try to connect with the proxytype HttpConnect i get the response: error Invalid HTTP response.
and this log entry:
2013-05-21 10:01:01.953 Opening log file.
2013-05-21 10:01:02.009 INFO Ftp(1)[10] Info: Connecting to XXXXXXX:XXX using Ftp 4.0.4700.0 (trial version).
2013-05-21 10:01:02.010 INFO Ftp(1)[10] Info: Using proxy HTTP CONNECT PROXYXXX:XXX.
2013-05-21 10:01:02.150 ERROR Ftp(1)[10] Info: Rebex.Net.FtpException: Invalid HTTP response. ---> Rebex.Net.ProxySocketException: Invalid HTTP response.
at gbMKS.1vL03D.1fZglFZ(String )
at gbMKS.ULE4T.1fZglFZ(IAsyncResult , String , Int32 )
at gbMKS.ULE4T.1QP6MBZ(IAsyncResult , Int32 )
at Rebex.Net.ProxySocket.EndConnect(IAsyncResult asyncResult)
at gbMKS.l7gsR..ctor(Ftp ftp, ISocketFactory factory, String serverName, Int32 serverPort)
at Rebex.Net.Ftp.2eOMSNZ(String , Int32 , TlsParameters , FtpSecurity )
--- End of inner exception stack trace ---
at Rebex.Net.Ftp.2eOMSNZ(String , Int32 , TlsParameters , FtpSecurity )
And if i try it with the proxytype ftpOpen i get the response: error
TLS/SSL through FTP proxy is not possible.
and this entry in the log:
2013-05-21 10:04:10.463 Opening log file.
2013-05-21 10:04:10.563 ERROR Ftp(1)[10] Info: System.InvalidOperationException: TLS/SSL through FTP proxy is not possible.
at Rebex.Net.Ftp.2eOMSNZ(String , Int32 , TlsParameters , FtpSecurity )
I also tried something i learned when reading up on the .net ftp libraries, apparently they need the ftp:// prefix infront of the adresses, i tried this also but got the same response.
I am also able to establish a connection with the ftp site with CuteFtp, so i do not know why i cannot get a connection myself.
Is there anyone who have successfully managed to connect to an ftp site through a proxy using TSL/SSL?
Or does anyone else see a glaring error in my code that i do not see?