How to use FTPS?

0 votes
asked Apr 30, 2010 by Philippe Millette (180 points)
edited May 10, 2010

Hi, I'm currently to make my connection to my FileZilla server that uses the FTPS. What I found in the samples is something as simple as setting up the TlsParameters and add myFTP.Secure(tlsparam) and it works ...

I copy the code from a sample ...and I am able to connect on my FTP Server with those sample but in my code ...I'm not able to.

I started with the sample: ResumableTransfert sample and I checked the "TLS/SSL" and "Do not validate any server certificates - this is insecure but useful for testing." ...at first it didn't work.

After, I tried with the WinFormClient setting up the parameters FTPS over Implicit SSL ...I manually accepted the certificate and I got connected...

After that, I went back into the ResumableTransfert and I was finally able to connect with the same settings as before! I guess my certificate was saved somewhere that I cannot find from the samples ...but I would like to accept that certificate all the time ..is there anyway ????

I get a connection on my FTP server ...I get only the welcome message (code 220) and I got a Timeout exception after that...on the line "myFTP.Connect(...)"

    Dim myFTP As New Ftp
    Dim paramSecure As New TlsParameters

    paramSecure.CommonName = ses.serverName
    paramSecure.CertificateVerifier = CertificateVerifier.AcceptAll

    With myFTP

        Try
            .SecureTransfers = True
            .Connect(ses.serverName, ses.port)
            .Secure(paramSecure)
            .Login(ses.username, ses.password)
            .Disconnect()

        Catch ex As Exception
            Response.Write(ex.Message.ToString)
        Finally
            .Dispose()
        End Try
    End With

Thanks!

Applies to: Rebex FTP/SSL
commented Apr 30, 2010 by Philippe Millette (180 points)
I forgot to say, I'm currently using Rebex FTP/SSL for .NET 2.5.2800.0 ...thanks!

2 Answers

+1 vote
answered Apr 30, 2010 by Philippe Millette (180 points)
edited Apr 30, 2010

Well, after a lot of testing ...I finally made it through ...here's my code

    Dim myFTP As New Ftp
    Dim p As New TlsParameters

    p.CommonName = ses.serverName
    p.CertificateVerifier = CertificateVerifier.AcceptAll
    p.AllowedSuites = TlsCipherSuite.All
    p.Version = TlsVersion.SSL30

    With myFTP

        Try
            .SecureTransfers = True

            Dim ar As IAsyncResult = .BeginConnect(ses.serverName, ses.port, p, FtpSecurity.Implicit, Nothing, Nothing)
            While Not ar.IsCompleted
                System.Threading.Thread.Sleep(1)
            End While
            .EndConnect(ar)

            .Login(ses.username, ses.password)
commented May 3, 2010 by Lukas Pokorny (99,010 points)
Sorry for not replying earlier - on weekends, we only check the forum occasionally.
commented May 3, 2010 by Lukas Pokorny (99,010 points)
I would remove the "p.Version = TlsVersion.SSL30" line - this disables TLS 1.0, which is actually newer than SSL 3.0 (simply said, TLS 1.0 is SSL 3.1) and should be preferred.
+1 vote
answered May 3, 2010 by Lukas Pokorny (99,010 points)
edited May 3, 2010

Please check out our HOWTO on solving the "Server certificate was rejected by the verifier" exception. This describes several methods of solving the issue and also mentions their pros and cons.

...