.Net FTPS Connection times out after sending 'CCC' command

694 views Asked by At

I've been struggling a lot these last few days with a FTPS server that requires the 'CCC' command I'm trying to access via .Net

I'm using AlexFTPS Library. I'm able to connect and negociate AUTH TLS, I'm able to change directory but when I'm trying to list directory or download files, server asks for 'CCC' command. When I send 'CCC' command, I get a '200 CCC Context Enabled' reply but then I cannot send anything else, anytime I get a server timeout exception.

I've done further tests :

  • WS_FTP : works if I check the 'Use unencrypted command channel after SSL authentication' option
  • Filezilla : does not work even if I add 'CCC' as a Post Login Command
  • http://www.componentpro.com/ftp.net/ : works but is not open source

Any help would be so much appreciated... Sorry I am not FTP fluent...

Here's my code :

    Using Client As New AlexPilotti.FTPS.Client.FTPSClient

        AddHandler Client.LogCommand, Sub(sender As Object, args As AlexPilotti.FTPS.Common.LogCommandEventArgs)
                                          Console.WriteLine(args.CommandText)
                                      End Sub

        AddHandler Client.LogServerReply, Sub(sender As Object, args As AlexPilotti.FTPS.Common.LogServerReplyEventArgs)
                                              Console.WriteLine(args.ServerReply)
                                          End Sub

        Dim cred = New Net.NetworkCredential("login", "password")
        Client.Connect("ftps.server.com", cred, AlexPilotti.FTPS.Client.ESSLSupportMode.CredentialsRequired)

        Client.SendCustomCommand("SYST")
        Client.SendCustomCommand("PBSZ 0")
        Client.SendCustomCommand("PROT P")
        Client.SendCustomCommand("FEAT")
        Client.SendCustomCommand("PWD")
        Client.SendCustomCommand("TYPE A")
        Client.SendCustomCommand("PASV")
        Client.SendCustomCommand("CCC")
        Client.SendCustomCommand("LIST")

        Console.ReadKey()

    End Using

Thanks !

1

There are 1 answers

1
Steffen Ullrich On

CCC ("Clear Command Channel") is a special command which downgrades the connection from SSL (started with AUTH TLS) back to unencrypted again. So it's no enough to just declare it as a custom command which gets send on the established control connection, it has to be handled similar to AUTH TLS by the FTPS library so that after the command is done the TLS downgrade occurs.