From 4a5525d1afad413c19761cd1fb36eb4a58b7a7b7 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Wed, 15 Aug 2018 20:43:21 +0000 Subject: [PATCH] Ensure that TLS 1.2 is enabled for web downloads. --- OpenRA.Game/Download.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/OpenRA.Game/Download.cs b/OpenRA.Game/Download.cs index 9e8a456d71..9fae0d1f51 100644 --- a/OpenRA.Game/Download.cs +++ b/OpenRA.Game/Download.cs @@ -43,8 +43,19 @@ namespace OpenRA } } + void EnableTLS12OnWindows() + { + // Enable TLS 1.2 on Windows: .NET 4.7 on Windows 10 only supports obsolete protocols by default + // SecurityProtocolType.Tls12 is not defined in the .NET 4.5 reference dlls used by mono, + // so we must use the enum's constant value directly + if (Platform.CurrentPlatform == PlatformType.Windows) + ServicePointManager.SecurityProtocol |= (SecurityProtocolType)3072; + } + public Download(string url, string path, Action onProgress, Action onComplete) { + EnableTLS12OnWindows(); + lock (syncObject) { wc = new WebClient { Proxy = null }; @@ -56,6 +67,8 @@ namespace OpenRA public Download(string url, Action onProgress, Action onComplete) { + EnableTLS12OnWindows(); + lock (syncObject) { wc = new WebClient { Proxy = null };