Newsgroups : Borland : borland.public.delphi.internet.winsock : 2008 Feb : Re: Encrypting TCP
| Subject: | Re: Encrypting TCP |
| Posted by: | "e1" (than..@but-no-thanks.com) |
| Date: | Mon, 4 Feb 2008 12:18:51 |
E Sterrett wrote:
> I have 2 delphi programs that communicate using TIdTCPServer and
> TIdTCPClient (Indy 10).
>
> How hard would it be to secure these connections using some kind of
> public key encryption (like SSL)?
>
> Are there any good examples out there?
>
> Thanks for any help.
I'm using Indy 9.
On the server side:
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}
if GlobalVar.EnableSSL then
begin
SSL := TIdServerIOHandlerSSL.Create(nil);
SSLPassword := GlobalVar.SSLPassword;
with SSL do
begin
SSLOptions.Method := sslvSSLv23;
SSLOptions.RootCertFile := GlobalVar.RootCertFile;
SSLOptions.CertFile := GlobalVar.CertFile;
SSLOptions.KeyFile := GlobalVar.KeyFile;
OnGetPassword := SSLOnGetPassword;
end;
Server.IOHandler := SSL;
end;
On the client side:
Client := TIdTCPClient.Create(nil);
Client.Port := DEFAULT_FAX_SERVER_PORT;
Client.Host := FIPAddr;
{SSL begin}
if GlobalVar.EnableSSL then
begin
SSL := TIdSSLIOHandlerSocket.Create(nil);
with SSL.SSLOptions do
begin
Method := sslvSSLv23;
Mode := sslmClient;
end;
Client.IOHandler := SSL;
end;
you will need SSL DLLs:
http://www.indyproject.org/Sockets/SSL.EN.aspx
-ioan
none