I'm adding SSL encryption to an existing project in Delphi 7 using a TCP Server and Client with no certificates. I've attached the required SSL IOHandler
s in each program, set the PassThrough
to False in the OnConnected
/Execute
procedures, and the error I get during a connection attempt is:
Error connecting with SSL.
error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure.
Using OpenSSL 1.0.2 DLL's, latest Indy10 from GitHub. I've used SSL with TIdHTTP
with no issues.
I've been reading every search item on the subject but cannot find a solution.
Here is the TCPServer DFM.
object TCPServer: TIdTCPServer
Bindings = <>
DefaultPort = 2323
IOHandler = SSLHandler
OnConnect = TCPServerConnect
OnDisconnect = TCPServerDisconnect
OnException = TCPServerException
OnListenException = TCPServerListenException
OnExecute = TCPServerExecute
end
object SSLHandler: TIdServerIOHandlerSSLOpenSSL
SSLOptions.Method = sslvSSLv23
SSLOptions.Mode = sslmServer
SSLOptions.VerifyMode = []
SSLOptions.VerifyDepth = 0
SSLOptions.Versions = [sslvTLSv1_2]
end
procedure TVTServerForm.TCPServerConnect(AContext: TIdContext);
begin
TIdSSLIOHandlerSocketBase(AContext.Connection.IOHandler).Passthrough := False;
end;
procedure TVTServerForm.TCPServerExecute(AContext: TIdContext);
begin
Cmd := Trim(AContext.Connection.IOHandler.ReadLn);
if Cmd = 'Login' then etc
TCPClient DFM...
object TCPClient: TIdTCPClient
IOHandler = SSLHandler
OnDisconnected = TCPClientDisconnected
OnWork = TCPClientWork
OnConnected = TCPClientConnected
ConnectTimeout = 10000
IPVersion = Id_IPv4
Port = 2323
ReadTimeout = 100000
Left = 728
Top = 468
end
object SSLHandler: TIdSSLIOHandlerSocketOpenSSL
Destination = ':2323'
MaxLineAction = maException
Port = 2323
DefaultPort = 0
ReadTimeout = 100000
SSLOptions.Method = sslvSSLv23
SSLOptions.Mode = sslmClient
SSLOptions.VerifyMode = []
SSLOptions.VerifyDepth = 0
SSLOptions.SSLVersions := [sslvTLSv1_2]
end
procedure TMainForm.TCPClientConnected(Sender: TObject);
var Ret: string;
begin
TIdSSLIOHandlerSocketBase(TCPClient.IOHandler).Passthrough := False;
TCPClient.IOHandler.Writeln('Login');
Ret := TCPClient.IOHandler.ReadLn;
etc
OnConnect
event would be more appropriate than theOnExecute
event to setPassThrough
unless the client is sending aSTARTTLS
-style command first.