Re: TcpIPServer and SSL

Giganews Newsgroups
Subject: Re: TcpIPServer and SSL
Posted by:  Ioan Ghip (delphi…
Date: Thu, 26 May 2005

Mustafa Shabib wrote:
> Hello All,
> I've written my client side component in C++ and it is cross platform;
> this is due to our client's requirements. I use OpenSSL for SSL security
> on the client side and, via some tests, have been able to make encrypted
> connections to https websites, etc so I believe it to be working. The
> server is written using and this is where I need help... can
> anyone post a tutorial or some kind of step-by-step on how to set up a
> TCP/IP server with SSL via
> Thank you in advance and I await your response.
> Mustafa

Hi Mustafa,
I don't use but here it's how I do it in indy.9 :-)

when I create the server:

    Server := TIDTCPServer.create(nil);
    ThreadMgr := TIdThreadMgrDefault.Create(nil);
    {Set Indy TCP server Properties}
    Server.ThreadMgr := ThreadMgr;

    Server.OnExecute := OnExecute;
    Server.OnConnect := OnConnect;
    Server.OnDisconnect := OnDisconnect;
    Server.TerminateWaitTime := 5000;
    Server.DefaultPort := DEFAULT_FAX_SERVER_PORT;
    {SSL Stuff begin}
    SSL := TIdServerIOHandlerSSL.Create(nil);
    SSLPassword := GlobalVar.SSLPassword;
    with SSL do
      SSLOptions.Method := sslvSSLv23;
      SSLOptions.RootCertFile := GlobalVar.RootCertFile;
      SSLOptions.CertFile := GlobalVar.CertFile;
      SSLOptions.KeyFile := GlobalVar.KeyFile;
      OnGetPassword := SSLOnGetPassword; <--- see below
    Server.IOHandler := SSL;

procedure TFaxTCPServer.SSLOnGetPassword(var Password: string);
  Password := SSLPassword;

and the client:

    ReadTimeout := avglobal.GlobalVar.ReadFromConnectionTimeOut;
    Client.Host := GlobalVar.LocalIP
    {SSL begin}
    SSL := TIdSSLIOHandlerSocket.Create(nil);
    with SSL.SSLOptions do
      Method := sslvSSLv23;
      Mode := sslmClient;
    Client.IOHandler := SSL;

of course, you need the ssl dlls.
libeay32.dll and ssleay32.dll



In response to

TcpIPServer and SSL posted by Mustafa Shabib on Fri, 20 May 2005