简体   繁体   English

强制 HttpWebRequest 和 ClientWebSocket 使用 TLS 1.2

[英]Force HttpWebRequest and ClientWebSocket to use TLS 1.2

I´m trying to connect to a websocket with the ClientWebSocket class.我正在尝试使用ClientWebSocket类连接到 websocket。 I´m using Unity 2017.4.10.我正在使用 Unity 2017.4.10。 Unfortunately C#/Mono is always using TLS 1.0 which for some reason fails.不幸的是,C#/Mono 总是使用 TLS 1.0,但由于某种原因失败了。 When i examine the connection with Wireshark i get a encrypted alert packet and the connection closes.当我检查与 Wireshark 的连接时,我收到一个加密的警报数据包并且连接关闭。

I already tried to force TLS 1.2 by setting:我已经尝试通过设置来强制使用 TLS 1.2:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

but still the WebSocket tries to connect with TLS 1.0.但 WebSocket 仍然尝试与 TLS 1.0 连接。

When connecting to wss://echo.websocket.org it works, as websocket.org only supports TLS 1.2.当连接到 wss://echo.websocket.org 时它可以工作,因为 websocket.org 只支持 TLS 1.2。 Unfortunately my provider still supports TLS 1.0 1.1 and 1.2.不幸的是,我的提供商仍然支持 TLS 1.0 1.1 和 1.2。 No matter what i try TLS 1.0 is always used by HttpWebRequest and ClientWebSocket classes.无论我尝试什么, HttpWebRequestClientWebSocket类总是使用 TLS 1.0。

I know TLS 1.0 is used because Wireshark and Fiddler says so.我知道使用 TLS 1.0 是因为 Wireshark 和 Fiddler 是这么说的。

Looks like this is a unity bug and fixed in 2018.2看起来这是一个统一错误并在 2018.2 中修复

Issue 问题

对于 Websocket 尝试: WebSocketClient.SslConfiguration.EnabledSslProtocols = System.Security.Authentication.SslProtocols.Tls12;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM