Delphi Intraweb ISAPI DLL failed to connect with server using TLS/SSL

327 Views Asked by At

I have a Delphi Intraweb application which is hosted on IIS using ISAPI DLL. This application internally connect with a Windows service application through IndyClient. Windows Service acts as an application server and written in Delphi itself.

I want to secure the communication performed between IndyClient and IndyServer (at Windows service side) through TLS/SSL. For this I am using TIdSSLIOHandlerSocketOpenSSL at client side and TIdServerIOHandlerSSLOpenSSL at service side. below code has been written in service side -

IdServerIOHandlerSSLOpenSSL1.SSLOptions.CertFile := Config.ServerCertificate; 
IdServerIOHandlerSSLOpenSSL1.SSLOptions.KeyFile := Config.ServerKey;

IdServerIOHandlerSSLOpenSSL1.SSLOptions.Mode := sslmServer;
IdServerIOHandlerSSLOpenSSL1.SSLOptions.VerifyMode := [];
IdServerIOHandlerSSLOpenSSL1.SSLOptions.VerifyDepth  := 0;
IdServerIOHandlerSSLOpenSSL1.SSLOptions.SSLVersions := [sslvTLSv1_2];

IndyServer.IOHandler := IdServerIOHandlerSSLOpenSSL1;
IndyServer.OnConnect := ServerConnect;

// Config object gets the correct path for certificate and key file

// Code for ServerConnect event 
if (AContext.Connection.IOHandler is TIdSSLIOHandlerSocketBase) then
   TIdSSLIOHandlerSocketBase(AContext.Connection.IOHandler).PassThrough := False;

Below code is written inside ISAPI DLL to connect with IndyServer

  IdSSLIOHandler.SSLOptions.VerifyMode := [];
  IdSSLIOHandler.SSLOptions.VerifyDepth := 0;
  IdSSLIOHandler.SSLOptions.SSLVersions := [sslvTLSv1_2];
  IdSSLIOHandler.SSLOptions.Mode := sslmClient;
  IndyClient.IOHandler := IdSSLIOHandler;
  TIdSSLIOHandlerSocketBase(IndyClient.IOHandler).PassThrough := False;

When I host the ISAPI DLL on IIS and try to connect with the Windows Service , getting below error message in Windows service side code -

EIdOSSLAcceptError with message 'Error accepting connection with SSL.EOF was observed that violates the protocol'

I have one desktop client application which connects with the same Windows service successfully using the same code written at client side.

I am using Self Signed certificates and tried configuring IIS to use HTTPS as well. My Delphi version is Delphi 10.2 Tokyo.

0

There are 0 best solutions below