Archived Forum Post

Index of archived forum posts

Question:

FTP2: How to turn off TLS after authenticating?

Oct 07 '16 at 19:34

I would like to use TLS to login, but then turn it off after that for both the control channel and the data channel. I tried this:

ftp.Hostname = hostName;
ftp.Username = userName;
ftp.Password = password;
ftp.AuthTls = true;

ftpResult = ftp.Connect();
LogFtpResponse(ftpResult);

ftp.ClearControlChannel();
ftp.DataProtection = "clear";

The first command after that was to GetCurrentRemoteDir, and it failed:

ChilkatLog:
  GetCurrentRemoteDir:
    DllDate: Sep 25 2016
    ChilkatVersion: 9.5.0.60
    UnlockPrefix: <removed>
    Architecture: Little Endian; 32-bit
    Language: .NET 4.6
    VerboseLogging: 0
    pwd:
      simpleCommand:
        sendCommand:
          prepControlChannel:
            unexpectedResponse: [=15=03=01=00 =0B=FCQ}=16=92=AA=A1=94=9B=A2=94=BBeT=9B]n}u=B7=1B*=F7Nz=AB=9C=C2*=FF6]
          --prepControlChannel
          sendingCommand: PWD
        --sendCommand
        readCommandResponse:
          Failed to read FTP control channel reply.
          readFtpReply: Socket operation timeout.
          receivedStrQP: [=15WD=00 =8CC=CD=E7   =F7bs=8F=1E=F0=0D4=DCX=A2=18=99;=C5E=05=B9a=DC=B97.E=11=B1@]
        --readCommandResponse
      --simpleCommand
    --pwd
    Failed.
  --GetCurrentRemoteDir
--ChilkatLog

It looks like there is a mismatch between what the client expects in terms of encrypted versus non-encrypted text.

So...

What is the recommended way to achieve TLS for the authentication only, then no encryption for all further traffic on both the control and data channels? Is it possible?


Answer

I'll have to give this a test. However, make sure to check the return value of ClearControlChannel. If it failed, then examine the LastErrorText.