Sample code for 30+ languages & platforms
Lazarus Pascal

Set the FTP TLS Version and Ciphers

See more FTP Examples

Demonstrates the TLS negotiation properties SslProtocol and SslAllowedCiphers, and reads back the negotiated TlsVersion and TlsCipherSuite after connecting.

Background: SslProtocol sets the allowed (or minimum) TLS version — default lets Chilkat negotiate the best available, while a value like TLS 1.2 or higher enforces a floor for policy compliance. SslAllowedCiphers narrows the offered cipher suites, which most applications should leave at the secure defaults. The read-only TlsVersion and TlsCipherSuite report what was actually agreed, useful for logging and audits.

Chilkat Lazarus Pascal Downloads

Lazarus Pascal
program ChilkatDemo;

// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.

{$IFDEF FPC}
  {$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}

uses
  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
  SysUtils,
  CkDllLoader,
  Chilkat.Ftp2;

// ---------------------------------------------------------------------------

procedure RunDemo;
var
  success: Boolean;
  ftp: TFtp2;

begin
  success := False;

  ftp := TFtp2.Create;

  ftp.Hostname := 'ftp.example.com';
  ftp.Username := 'myFtpLogin';

  ftp.AuthTls := True;

  //  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';

  //  Require at least TLS 1.2.  Accepted values include "default", "TLS 1.3", "TLS 1.2",
  //  "TLS 1.2 or higher", and so on.  "default" lets Chilkat negotiate the best available.
  ftp.SslProtocol := 'TLS 1.2 or higher';

  //  Optionally restrict the cipher suites offered.  Leave empty to use Chilkat's secure defaults.
  ftp.SslAllowedCiphers := 'TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256';

  success := ftp.Connect();
  if (success = False) then
    begin
      WriteLn(ftp.LastErrorText);
      Exit;
    end;

  //  After connecting, read back what was actually negotiated.
  WriteLn('Negotiated TLS version: ' + ftp.TlsVersion);
  WriteLn('Negotiated cipher suite: ' + ftp.TlsCipherSuite);

  success := ftp.Disconnect();
  if (success = False) then
    begin
      WriteLn(ftp.LastErrorText);
      Exit;
    end;


  ftp.Free;

end;

// ---------------------------------------------------------------------------

begin

  try
    RunDemo;
  except
    on E: Exception do
      WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
  end;

  WriteLn;
  {$IFDEF MSWINDOWS}
  WriteLn('Press Enter to exit...');
  ReadLn;
  {$ENDIF}
end.