Sample code for 30+ languages & platforms
PowerBuilder

FTP over Implicit TLS (Ssl, AuthSsl, AutoFix)

See more FTP Examples

Demonstrates the SSL/TLS connection-mode properties Ssl, AuthSsl, and AutoFix. Setting Ssl true selects implicit FTPS, in which TLS begins immediately after the TCP connection on port 990.

Background: FTP has two ways to add TLS: implicit (this example) starts encrypted from the first byte on a dedicated port, 990; explicit (via AuthTls) connects in the clear on port 21 and issues AUTH TLS to upgrade. Explicit is the modern standard; implicit persists mainly for legacy servers. AuthSsl is an obsolete AUTH SSL variant to avoid. AutoFix, on by default, infers the mode from the port — disable it when you set these properties explicitly so it does not override your choice.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Ftp

li_Success = 0

loo_Ftp = create oleobject
li_rc = loo_Ftp.ConnectToNewObject("Chilkat.Ftp2")
if li_rc < 0 then
    destroy loo_Ftp
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Ftp.Hostname = "ftp.example.com"
loo_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.
loo_Ftp.Password = "myPassword"

//  Ssl = 1 selects IMPLICIT FTPS: TLS begins immediately after the TCP connection, before
//  the greeting.  Port 990 is conventional for implicit FTPS.  Ssl takes priority over AuthTls
//  and AuthSsl.
loo_Ftp.Ssl = 1
loo_Ftp.Port = 990

//  AuthSsl selects the legacy AUTH SSL command and is very uncommon -- use AuthTls (explicit
//  FTPS) for modern servers instead.  Left 0 here.
loo_Ftp.AuthSsl = 0

//  AutoFix (default 1) automatically adjusts Ssl/AuthTls/AuthSsl based solely on the Port
//  (21 or 990).  Disable it when setting these properties explicitly, as here.
loo_Ftp.AutoFix = 0

li_Success = loo_Ftp.Connect()
if li_Success = 0 then
    Write-Debug loo_Ftp.LastErrorText
    destroy loo_Ftp
    return
end if

Write-Debug "Connected using implicit FTPS."

li_Success = loo_Ftp.Disconnect()
if li_Success = 0 then
    Write-Debug loo_Ftp.LastErrorText
    destroy loo_Ftp
    return
end if



destroy loo_Ftp