0 votes
by (230 points)
edited

Hi all -

I'm experimenting with Rebex FTP+SSL and have it working with FileZilla Server and FTP+SSL Explicit.

Since I only installed a self-signed cert within FileZilla and have it installed on my local development machine, I'm trying to test a simple C# console application.

If I use this code:

parameters.CertificateVerifier = CertificateVerifier.AcceptAll; ftp.Connect(hostname, 21, parameters, FtpSecurity.Explicit);`

I can get logged in and everything is fine.

I implemented my own CustomVerifier and have it returning:

return TlsCertificateAcceptance.Other

false since I want to do some exception handling. Problem is, I have wrapped the following code within a try/catch and I seem to be getting an "The Application Has Stopped Working" window when it fails the certificate check... when I click Cancel, then the console window will display the exception -- but not from my try/catch.

What am I doing wrong? I want to get this working as a console application first so I can port it to a windows service... and I have to assume I will get certificate errors sometimes and need to handle it gracefully without crashing the service.

Any help or insight would be appreciated.

The try/catch below never seems to be used:

                try
                {
                    ftp.Connect(hostname, port, par, FtpSecurity.Explicit);
                }
                catch (FtpException e)
                {
                    Console.WriteLine("Exception: {0}", e.Message);
                    Environment.Exit(1);

                }

After clicking the application has stopped working window, the DOS window then displays below:

Response: 220-FileZilla Server version 0.9.40 beta Response: 220-written by Tim Kosse (Tim.Kosse@gmx.de) Response: 220 Please visit http://sourceforge.net/projects/filezilla/ Command: AUTH TLS Response: 234 Using authentication type TLS

Unhandled Exception: Rebex.Net.TlsException: Server certificate was rejected by the verifier because of other problem. - --> Rebex.Net.TlsException: Server certificate was rejected by the verifier because of other problem. ---> Rebex.Net.Tls Exception: Server certificate was rejected by the verifier because of other problem. at wWGvS.AsKBXeZ.BiNSFl(String , CertificateChain ) at wWGvS.AsKBXeZ.AuxmRo(Byte[] , Int32 , Int32 , cEEfuOZ ) at wWGvS.AsKBXeZ.OnHandshakeReceived(Byte[] buffer, Int32 offset, Int32 count) at wWGvS.ckSCApZ.CzzDw(Byte[] , Int32 , Int32 ) at wWGvS.ckSCApZ.cDtmAOZ() --- End of inner exception stack trace --- at wWGvS.ckSCApZ.cDtmAOZ() at wWGvS.ckSCApZ.ArwjUr() at Rebex.Net.TlsSocket.Negotiate() at wWGvS.AgXIfM.AUXDmhZ(TlsParameters ) at Rebex.Net.Ftp.BLyBkd(TlsParameters , FtpSecureUpgradeType ) at Rebex.Net.Ftp.Connect(String serverName, Int32 serverPort, TlsParameters parameters, FtpSecurity security) --- End of inner exception stack trace --- at Rebex.Net.Ftp.Connect(String serverName, Int32 serverPort, TlsParameters parameters, FtpSecurity security) at RebexFTPSConsoleTest.Program.Main(String[] args) in c:usersdm3281documentsvisual studio 2010ProjectsRebexFT PSConsoleTestRebexFTPSConsoleTestProgram.cs:line 101

Line 101 is the the Ftp.Connect() line.

Applies to: Rebex FTP/SSL

1 Answer

0 votes
by (144k points)
edited
 
Best answer

Try catching TlsException:

            try
            {
                ftp.Connect(hostname, port, par, FtpSecurity.Explicit);
            }
            catch (FtpException e)
            {
                Console.WriteLine("Exception: {0}", e.Message);
                Environment.Exit(1);

            }

This is what is raised in response to TlsCertificateAcceptance.Other.

by (230 points)
edited

Thank you!

...