WebSockets SSL version: TLS 1.0, 1.1, 1.2

When a WebSocket server requires secure connections, you can get an error message like this when a client tries to connect to server:


  Error connecting with SSL. error:XXXXXXXX:SSL routines:ssl3_read_bytes:tlsv1 alert protocol version


This error means that your client is trying to connect using a TLS version which is not supported by server. To resolver this error you must handle OnSSLAfterCreateHandler of websocket client component and set a newer TLS version. For example: here we are setting TLS 1.2 as protocol version.


procedure OnSSLAfterCreateHandler(Sender: TObject; aType: TwsSSLHandler; aSSLHandler: TIdSSLIOHandlerSocketBase);
   TIdServerIOHandlerSSLOpenSSL(aSSLHandler).SSLOptions.Method:= sslvTLSv1_2;