From dfb6ee0f29e7601d6aecf6d95386336afdcb7ab3 Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Wed, 24 Apr 2024 21:17:38 +0200 Subject: [PATCH] Updated TLS version to `None` or `SystemDefault` to use the OS "best match" versions. --- Duplicati.Library.RestAPI/WebServer/Server.cs | 3 +- .../GUI/Duplicati.GUI.TrayIcon/Program.cs | 2 +- .../Library/Modules/Builtin/HttpOptions.cs | 57 +++++++------------ 3 files changed, 24 insertions(+), 38 deletions(-) diff --git a/Duplicati.Library.RestAPI/WebServer/Server.cs b/Duplicati.Library.RestAPI/WebServer/Server.cs index a6922b4e2..c215c5ab5 100644 --- a/Duplicati.Library.RestAPI/WebServer/Server.cs +++ b/Duplicati.Library.RestAPI/WebServer/Server.cs @@ -162,8 +162,7 @@ namespace Duplicati.Server.WebServer if (certValid) { - var secProtocols = System.Security.Authentication.SslProtocols.Tls12 | System.Security.Authentication.SslProtocols.Tls13; - server.Start(listenInterface, p, cert, secProtocols, null, false); + server.Start(listenInterface, p, cert, System.Security.Authentication.SslProtocols.None, null, false); } else { diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/Program.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/Program.cs index 2493ea3f5..a928ca5f4 100644 --- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/Program.cs +++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/Program.cs @@ -184,7 +184,7 @@ namespace Duplicati.GUI.TrayIcon { try { - ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13; + ServicePointManager.SecurityProtocol = SecurityProtocolType.SystemDefault; using (Connection = new HttpServerConnection(serverURL, password, saltedpassword, databaseConnection != null ? PasswordSource.Database : PasswordSource.HostedServer, disableTrayIconLogin, options)) { using (var tk = RunTrayIcon()) diff --git a/Duplicati/Library/Modules/Builtin/HttpOptions.cs b/Duplicati/Library/Modules/Builtin/HttpOptions.cs index f21866c45..251dcdf07 100644 --- a/Duplicati/Library/Modules/Builtin/HttpOptions.cs +++ b/Duplicati/Library/Modules/Builtin/HttpOptions.cs @@ -1,23 +1,23 @@ -// Copyright (C) 2024, The Duplicati Team -// https://duplicati.com, hello@duplicati.com -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. +// Copyright (C) 2024, The Duplicati Team +// https://duplicati.com, hello@duplicati.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. using System; using System.Collections.Generic; @@ -60,25 +60,12 @@ namespace Duplicati.Library.Modules.Builtin /// private IDisposable m_oauthsettings; - // Copied from system reference - [Flags] - private enum CopySecurityProtocolType - { - Ssl3 = 48, - Tls = 192, - Tls11 = 768, - Tls12 = 3072, - } - private static Dictionary SecurityProtocols { get { var res = new Dictionary(StringComparer.OrdinalIgnoreCase); - foreach (var val in Enum.GetNames(typeof(CopySecurityProtocolType)).Zip(Enum.GetValues(typeof(CopySecurityProtocolType)).Cast(), (x,y) => new KeyValuePair(x, y))) - res[val.Key] = val.Value; - - foreach (var val in Enum.GetNames(typeof(System.Net.SecurityProtocolType)).Zip(Enum.GetValues(typeof(System.Net.SecurityProtocolType)).Cast(), (x,y) => new KeyValuePair(x, y))) + foreach (var val in Enum.GetNames(typeof(System.Net.SecurityProtocolType)).Zip(Enum.GetValues(typeof(System.Net.SecurityProtocolType)).Cast(), (x, y) => new KeyValuePair(x, y))) res[val.Key] = val.Value; return res; @@ -122,7 +109,7 @@ namespace Duplicati.Library.Modules.Builtin { get { var sslnames = SecurityProtocols.Select(x => x.Key).ToArray(); - var defaultssl = string.Join(",", Enum.GetValues(typeof(System.Net.SecurityProtocolType)).Cast().Where(x => System.Net.ServicePointManager.SecurityProtocol.HasFlag(x))); + var defaultssl = System.Net.SecurityProtocolType.SystemDefault.ToString(); return new List( new Duplicati.Library.Interface.ICommandLineArgument[] { new Duplicati.Library.Interface.CommandLineArgument(OPTION_DISABLE_EXPECT100, Duplicati.Library.Interface.CommandLineArgument.ArgumentType.Boolean, Strings.HttpOptions.DisableExpect100Short, Strings.HttpOptions.DisableExpect100Long, "false"),