TsgcWebSocketLoadBalancerServer › Events › OnSSLGetHandler
Fires before the SSL handler is created so a custom server-side handler instance can be supplied to the load balancer.
property OnSSLGetHandler: TsgcWSOnSSLGetHandler;
// TsgcWSOnSSLGetHandler = procedure(Sender: TObject; aType: TwsSSLHandler; var aSSLHandler: TIdServerIOHandlerSSLBase) of object
—
OnSSLGetHandler is raised just before the load balancer builds the TLS IOHandler used for SSL bindings. Assign aSSLHandler to an instance of your own class inherited from TIdServerIOHandlerSSLBase to replace the default handler, for example to plug a specialized OpenSSL or SChannel implementation. Leave aSSLHandler unassigned to let the component create the default handler; in that case OnSSLAfterCreateHandler can still be used to tweak properties after creation. The component takes ownership of the handler assigned here and will free it when the server is destroyed.
When IOHandlerOptions.IOHandlerType is iohIOCP or iohEPOLL, only a handler that inherits from TsgcIdServerIOHandlerOpenSSLIOCP (IOCP) or TsgcIdServerIOHandlerOpenSSLEPOLL (EPOLL) can be driven by the event-driven IO engine. The IOHandlerOptions values, such as threads, timeouts and TCPKeepAlive, are applied to such a handler before OnSSLAfterCreateHandler fires, so values set in that event take precedence. Any other handler still works, for example a third party TLS implementation or an SChannel handler. The load balancer detects it when it starts, runs with the classic thread per connection engine instead of the event-driven one, and reports it through the OnError event. Read the ActiveIOHandlerType property to know which engine is really running. If you only need to change a few properties of the default handler, use OnSSLAfterCreateHandler instead of replacing the handler. To drive the event-driven engine with a TLS library other than OpenSSL, descend from TsgcIdServerIOHandlerTLSIOCP or TsgcIdServerIOHandlerTLSEPOLL and supply your own TLS provider, as described in TLS Provider.
procedure OnSSLGetHandler(Sender: TObject; aType: TwsSSLHandler;
var aSSLHandler: TIdServerIOHandlerSSLBase);
begin
aSSLHandler := TCustomServerSSLHandler.Create(nil);
// ... configure handler properties
end;