Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to redirect http to https in TIdCustomHTTPServer
#1
Hello Guys,

I am trying to do a service that works under ssl, but that I redirect the http connections to https and I have not succeeded. Is it possible to do that?
I need to use port 9001 so I also can not bind on two different ports, so I need only redirect https:\\example.com to https:\\example.com.

My implementation:
Code:
 sslHandler := TIdServerIOHandlerSSLOpenSSL.Create(nil);
 sslHandler.SSLOptions.KeyFile := GetCurrentDir + '\certificados\private.key';
 sslHandler.SSLOptions.CertFile := GetCurrentDir + '\certificados\certificate.crt';
 sslHandler.SSLOptions.RootCertFile := GetCurrentDir + '\certificados\ca_bundle.crt';
 sslHandler.SSLOptions.Mode := sslmServer;
 sslHandler.SSLOptions.SSLVersions  := [sslvTLSv1, sslvSSLv2, sslvSSLv23, sslvSSLv3, sslvTLSv1_1, sslvTLSv1_2];
 sslHandler.SSLOptions.VerifyDepth  := 0;
 sslHandler.SSLOptions.VerifyMode   := [];
 sslHandler.OnGetPassword := IdServerIOHandlerSSLOpenSSLGetPassword;
 
 Server.OnConnect := onConect;
 Server.IOHandler := sslHandler;

and 

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


Thank you!
Reply


Messages In This Thread
How to redirect http to https in TIdCustomHTTPServer - by ermesoml - 06-08-2018, 02:56 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)