From b3b90602a25241b9f5e6c52b18be96f171334839 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 28 Oct 2017 17:43:46 -0400 Subject: [PATCH] Fix Mono SecurityProtocolPolicy --- .../Security/SecurityProtocolPolicy.cs | 9 +++- .../HealthCheck/Checks/MonoTlsCheck.cs | 41 +++++++++++++++++++ src/NzbDrone.Core/NzbDrone.Core.csproj | 1 + 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/NzbDrone.Core/HealthCheck/Checks/MonoTlsCheck.cs diff --git a/src/NzbDrone.Common/Security/SecurityProtocolPolicy.cs b/src/NzbDrone.Common/Security/SecurityProtocolPolicy.cs index 03fcb97d2..c0ebc56eb 100644 --- a/src/NzbDrone.Common/Security/SecurityProtocolPolicy.cs +++ b/src/NzbDrone.Common/Security/SecurityProtocolPolicy.cs @@ -1,6 +1,7 @@ -using System; +using System; using System.Net; using NLog; +using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Instrumentation; namespace NzbDrone.Common.Security @@ -14,6 +15,12 @@ namespace NzbDrone.Common.Security public static void Register() { + if (OsInfo.IsNotWindows) + { + // This was never meant to be used on mono, and will cause issues with mono 5 and higher if btls is enabled. + return; + } + try { // TODO: In v3 we should drop support for SSL3 because its very insecure. Only leaving it enabled because some people might rely on it. diff --git a/src/NzbDrone.Core/HealthCheck/Checks/MonoTlsCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/MonoTlsCheck.cs new file mode 100644 index 000000000..a3a0226a6 --- /dev/null +++ b/src/NzbDrone.Core/HealthCheck/Checks/MonoTlsCheck.cs @@ -0,0 +1,41 @@ +using System; +using System.Linq; +using System.Reflection; +using NLog; +using NzbDrone.Common.EnvironmentInfo; + +namespace NzbDrone.Core.HealthCheck.Checks +{ + public class MonoTlsCheck : HealthCheckBase + { + private readonly IPlatformInfo _platformInfo; + private readonly Logger _logger; + + public MonoTlsCheck(IPlatformInfo platformInfo, Logger logger) + { + _platformInfo = platformInfo; + _logger = logger; + } + + public override HealthCheck Check() + { + if (!PlatformInfo.IsMono) + { + return new HealthCheck(GetType()); + } + + var monoVersion = _platformInfo.Version; + + if (monoVersion >= new Version("5.0.0") && Environment.GetEnvironmentVariable("MONO_TLS_PROVIDER") == "legacy") + { + // Mono 5.0 still has issues in combination with libmediainfo, so disabling this check for now. + //_logger.Debug("Mono version 5.0.0 or higher and legacy TLS provider is selected, recommending user to switch to btls."); + //return new HealthCheck(GetType(), HealthCheckResult.Warning, "Sonarr now supports Mono 5.x with btls enabled, consider removing MONO_TLS_PROVIDER=legacy option"); + } + + return new HealthCheck(GetType()); + } + + public override bool CheckOnSchedule => false; + } +} diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 1f88164de..993403028 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -446,6 +446,7 @@ +