Force HttpWebRequest and ClientWebSocket to use TLS 1.2

Viewed 3151

I´m trying to connect to a websocket with the ClientWebSocket class. I´m using Unity 2017.4.10. Unfortunately C#/Mono is always using TLS 1.0 which for some reason fails. When i examine the connection with Wireshark i get a encrypted alert packet and the connection closes.

I already tried to force TLS 1.2 by setting:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

but still the WebSocket tries to connect with TLS 1.0.

When connecting to wss://echo.websocket.org it works, as websocket.org only supports TLS 1.2. Unfortunately my provider still supports TLS 1.0 1.1 and 1.2. No matter what i try TLS 1.0 is always used by HttpWebRequest and ClientWebSocket classes.

I know TLS 1.0 is used because Wireshark and Fiddler says so.

2 Answers

Looks like this is a unity bug and fixed in 2018.2

Issue

for Websocket try : WebSocketClient.SslConfiguration.EnabledSslProtocols = System.Security.Authentication.SslProtocols.Tls12;

Related