FTPS - Secure FTP - EXAMPLE HELP

Giganews Newsgroups
Subject: FTPS - Secure FTP - EXAMPLE HELP
Posted by:  Mark Moss (markemo…@comcast.net)
Date: Sun, 28 Feb 2010

Ladies / Gentlemen / Remy etc.

    I have been trying to get this example to work for several days now =
and all I keep getting is '10054' error messages, or

    'Error Connecting with SSL' or=20

    The log shows the following for the '10054' error

Stat Connected.
Recv 2/28/2010 2:26:05 PM: 220 MPGAIX FTP server (Version 4.2 Wed Jun 3 =
15:43:49 CDT 2009) ready.<EOL>
Sent 2/28/2010 2:26:05 PM: AUTH TLS<EOL>
Recv 2/28/2010 2:26:05 PM: 234 Using authentication type TLSv1<EOL>
Stat Disconnected.

-------------------------

        Do you have any ideas on why I can not connect?

        Any help would be greatly appreciated.

Mark Moss

{++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
++++++++++++++++++}

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, =
Forms,
  Dialogs, StdCtrls, IdIOHandler, IdIOHandlerSocket, IdIOHandlerStack, =
IdSSL,
  IdSSLOpenSSL, IdBaseComponent, IdComponent, IdTCPConnection, =
IdTCPClient,
  IdExplicitTLSClientServerBase, IdFTP, IdFTPCommon, IdLogEvent, =
IdLogFile,
  IdIntercept, IdLogBase, IdLogDebug;

type
  TForm1 =3D class(TForm)

    Memo1                                        : TMemo;
    Button1                                      : TButton;
    IdFTP2                                      : TIdFTP;
    IdSSLIOHandlerSocketOpenSSL2                : =
TIdSSLIOHandlerSocketOpenSSL;
    IdLogFile1                                  : TIdLogFile;

    procedure IdFTP1Status(ASender: TObject; const AStatus: TIdStatus; =
const AStatusText: string);
    procedure Button1Click(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  IdSSLIOHandlerSocketOpenSSL1                  : =
TIdSSLIOHandlerSocketOpenSSL;
  IdFTP1                                        : TIdFTP;

begin

{------------------------------------------------------------------------=
------}

    IdSSLIOHandlerSocketOpenSSL1                          :=3D =
TIdSSLIOHandlerSocketOpenSSL.Create(NIL);
    IdSSLIOHandlerSocketOpenSSL1.SSLOptions.Method        :=3D =
sslvTLSv1;
    IdSSLIOHandlerSocketOpenSSL1.SSLOptions.Mode          :=3D =
sslmClient;

    IdSSLIOHandlerSocketOpenSSL1.Intercept                :=3D =
IdLogFile1;

{------------------------------------------------------------------------=
------}

    IdFTP1                                      :=3D =
TIdFTP.Create(NIL);
    IdFTP1.IOHandler                            :=3D =
IdSSLIOHandlerSocketOpenSSL1;
    IdFTP1.Passive                              :=3D TRUE;
    IdFTP1.UseTLS                              :=3D utUseImplicitTLS;
    IdFTP1.DataPortProtection                  :=3D ftpdpsPrivate;

{------------------------------------------------------------------------=
------}

    IdFTP1.Host                                :=3D '999.999.999.999';
    IdFTP1.Port                                :=3D 21;
    IdFTP1.Username                            :=3D 'NAME';
    IdFTP1.Password                            :=3D 'PASSWORD';

    IdFTP1.OnStatus                            :=3D IdFTP1Status;

{------------------------------------------------------------------------=
------}

    SELF.Memo1.Lines.Add('Trying to Connect.');

    try
        IdFTP1.Connect;
    finally

            if IdFTP1.Connected  then
              SELF.Memo1.Lines.Add('Connected.')
            else
              SELF.Memo1.Lines.Add('Failed to Connect.');

    end;

    IdFTP1.ChangeDir('/receive');

    IdFTP1.List(SELF.Memo1.Lines);

    IdFTP1.Disconnect;

{------------------------------------------------------------------------=
------}

end;

procedure TForm1.IdFTP1Status(ASender: TObject; const AStatus: =
TIdStatus; const AStatusText: string);
begin

    case AStatus of

        hsResolving:    Memo1.Lines.Add('A host name is being resolved =
to an IP Address.');
        hsConnecting:  Memo1.Lines.Add('A connection is being =
opened.');
        hsConnected:    Memo1.Lines.Add('A connection has been =
made.');
        hsDisconnecting: Memo1.Lines.Add('The connection is being =
closed.');
        hsDisconnected: Memo1.Lines.Add('The connection has been =
closed.');

    end;

    Application.ProcessMessages;

end;

end.

{++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
+++++++++++++++++}

object Form1: TForm1
  Left =3D 0
  Top =3D 0
  Caption =3D 'Form1'
  ClientHeight =3D 294
  ClientWidth =3D 467
  Color =3D clBtnFace
  Font.Charset =3D DEFAULT_CHARSET
  Font.Color =3D clWindowText
  Font.Height =3D -11
  Font.Name =3D 'Tahoma'
  Font.Style =3D []
  OldCreateOrder =3D False
  Position =3D poScreenCenter
  PixelsPerInch =3D 96
  TextHeight =3D 13
  object Memo1: TMemo
    Left =3D 0
    Top =3D 109
    Width =3D 467
    Height =3D 185
    Align =3D alBottom
    BevelInner =3D bvLowered
    BevelKind =3D bkTile
    ScrollBars =3D ssVertical
    TabOrder =3D 0
  end
  object Button1: TButton
    Left =3D 198
    Top =3D 42
    Width =3D 75
    Height =3D 25
    Caption =3D 'Button1'
    TabOrder =3D 1
    OnClick =3D Button1Click
  end
  object IdLogFile1: TIdLogFile
    Active =3D True
    Filename =3D 'IndyLog.txt'
    Left =3D 126
    Top =3D 30
  end
end

{++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
+++++++++++++++++}

Replies