Sample code for 30+ languages & platforms
Xojo Plugin

Revert an FTPS Control Channel to Clear Text (CCC)

See more FTP Examples

Demonstrates the Chilkat Ftp2.ClearControlChannel method, which requests that an explicit-FTPS control connection return to clear text after authentication. It takes no arguments. Data connections may remain protected according to the DataProtection property.

Background: The CCC (Clear Command Channel) command exists to solve an FTPS-through-NAT problem: because FTP negotiates data ports in the control channel, a firewall or NAT device must read those commands to open the right ports — which it cannot do when the control channel is encrypted. Reverting the control channel to clear text after login lets the network device help, while the data channel can stay protected. It weakens security on the control channel, so use it only when the network requires it.

Chilkat Xojo Plugin Downloads

Xojo Plugin
Dim success As Boolean
success = False

//  Demonstrates the Ftp2.ClearControlChannel method, which requests that an explicit-FTPS control
//  connection return to clear text after authentication.  It takes no arguments.

Dim ftp As New Chilkat.Ftp2

ftp.Hostname = "ftp.example.com"
ftp.Username = "myFtpLogin"

//  Normally you would not hard-code the password in source.  You should instead obtain it
//  from an interactive prompt, environment variable, or a secrets vault.
ftp.Password = "myPassword"

//  Use explicit FTPS (AUTH TLS) on the standard FTP port.
ftp.AuthTls = True

success = ftp.Connect()
If (success = False) Then
    System.DebugLog(ftp.LastErrorText)
    Return
End If

//  After a secure login, revert the CONTROL channel to clear text (CCC command).  Data
//  connections may remain protected according to the DataProtection property.  This is sometimes
//  required so that NAT/firewall devices can inspect the control channel to open data ports.
success = ftp.ClearControlChannel()
If (success = False) Then
    System.DebugLog(ftp.LastErrorText)
    Return
End If

System.DebugLog("Control channel reverted to clear text.")

success = ftp.Disconnect()
If (success = False) Then
    System.DebugLog(ftp.LastErrorText)
    Return
End If