From d28952365f9730a239d6973246dbd0d7fe92651a Mon Sep 17 00:00:00 2001 From: inoussa Date: Sat, 27 Feb 2016 12:53:13 +0000 Subject: [PATCH] +Indy HTTPS support (Thanks Patrick Kolla-ten Venne). git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4524 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- wst/trunk/indy_http_server.pas | 3 +- wst/trunk/indy_https_server.pas | 59 +++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 wst/trunk/indy_https_server.pas diff --git a/wst/trunk/indy_http_server.pas b/wst/trunk/indy_http_server.pas index a8cf0fd9f..a8a8eab6a 100644 --- a/wst/trunk/indy_http_server.pas +++ b/wst/trunk/indy_http_server.pas @@ -43,8 +43,9 @@ type TwstIndyHttpListener = class(TwstListener) private - FHTTPServerObject: TIdHTTPServer; FRootAddress : string; + protected + FHTTPServerObject: TIdHTTPServer; private procedure ProcessWSDLRequest( {$IFDEF INDY_10} diff --git a/wst/trunk/indy_https_server.pas b/wst/trunk/indy_https_server.pas new file mode 100644 index 000000000..87e10d8ed --- /dev/null +++ b/wst/trunk/indy_https_server.pas @@ -0,0 +1,59 @@ +unit indy_https_server; + +interface + +uses + IdSSLOpenSSL, + indy_http_server; + +type + + { TwstIndyHttpsListener } + + TwstIndyHttpsListener = class(TwstIndyHttpListener) + private + FCertFile: string; + FIoHandler: TIdServerIOHandlerSSLOpenSSL; + FKeyFile: string; + FRootCertFile: string; + procedure SetCertFile(AValue: string); + procedure SetKeyFile(AValue: string); + procedure SetRootCertFile(AValue: string); + public + constructor Create(const AServerIpAddress: string = '127.0.0.1'; const AListningPort: integer = 8000; const ADefaultClientPort: integer = 25000; + const AServerSoftware: string = 'Web Service Toolkit Application'); + property CertFile: string read FCertFile write SetCertFile; + property RootCertFile: string read FRootCertFile write SetRootCertFile; + property KeyFile: string read FKeyFile write SetKeyFile; + end; + +implementation + +{ TwstIndyHttpsListener } + +procedure TwstIndyHttpsListener.SetCertFile(AValue: string); +begin + FIoHandler.SSLOptions.CertFile := AValue; +end; + +procedure TwstIndyHttpsListener.SetKeyFile(AValue: string); +begin + FIoHandler.SSLOptions.KeyFile := AValue; +end; + +procedure TwstIndyHttpsListener.SetRootCertFile(AValue: string); +begin + FIoHandler.SSLOptions.RootCertFile := AValue; +end; + +constructor TwstIndyHttpsListener.Create(const AServerIpAddress: string; const AListningPort: integer; const ADefaultClientPort: integer; const AServerSoftware: string); +begin + inherited Create(AServerIpAddress, AListningPort, ADefaultClientPort, AServerSoftware); + FIoHandler := TIdServerIOHandlerSSLOpenSSL.Create(nil); + // TIdSSLVersion = (sslvSSLv2, sslvSSLv23, sslvSSLv3, sslvTLSv1,sslvTLSv1_1,sslvTLSv1_2); + FIoHandler.SSLOptions.Method := sslvSSLv23; + FIoHandler.SSLOptions.Mode := sslmServer; + FHTTPServerObject.IOHandler := FIoHandler; +end; + +end.