From e0bf68123d0471abf01cac01f6844d894a3831d6 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 7 Jul 2013 10:19:08 -0700 Subject: [PATCH] ignore cert errors in linux http://www.mono-project.com/FAQ:_Security --- NzbDrone.Common/NzbDrone.Common.csproj | 1 + .../Security/IgnoreCertErrorPolicy.cs | 27 +++++++++++++++++++ NzbDrone.Console/NzbDrone.Console.csproj | 2 -- NzbDrone.Update/Program.cs | 4 +++ NzbDrone.ncrunchsolution | 1 + NzbDrone/AppMain.cs | 3 ++- 6 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 NzbDrone.Common/Security/IgnoreCertErrorPolicy.cs diff --git a/NzbDrone.Common/NzbDrone.Common.csproj b/NzbDrone.Common/NzbDrone.Common.csproj index cd7ad1b32..19f544460 100644 --- a/NzbDrone.Common/NzbDrone.Common.csproj +++ b/NzbDrone.Common/NzbDrone.Common.csproj @@ -110,6 +110,7 @@ + diff --git a/NzbDrone.Common/Security/IgnoreCertErrorPolicy.cs b/NzbDrone.Common/Security/IgnoreCertErrorPolicy.cs new file mode 100644 index 000000000..1be964380 --- /dev/null +++ b/NzbDrone.Common/Security/IgnoreCertErrorPolicy.cs @@ -0,0 +1,27 @@ +using System.Net; +using System.Net.Security; +using System.Security.Cryptography.X509Certificates; +using NLog; +using NzbDrone.Common.EnvironmentInfo; + +namespace NzbDrone.Common.Security +{ + public static class IgnoreCertErrorPolicy + { + private static readonly Logger Logger = LogManager.GetLogger("CertPolicy"); + + public static void Register() + { + if (OsInfo.IsLinux) + { + ServicePointManager.ServerCertificateValidationCallback = ValidationCallback; + } + } + + private static bool ValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslpolicyerrors) + { + Logger.Warn("[{0}] {1}", sender.GetType(), sslpolicyerrors); + return true; + } + } +} \ No newline at end of file diff --git a/NzbDrone.Console/NzbDrone.Console.csproj b/NzbDrone.Console/NzbDrone.Console.csproj index 5e6425b74..19075722b 100644 --- a/NzbDrone.Console/NzbDrone.Console.csproj +++ b/NzbDrone.Console/NzbDrone.Console.csproj @@ -43,7 +43,6 @@ 4 true BasicCorrectnessRules.ruleset - C:\Users\Mark\AppData\Local\Temp\vs1A55.tmp\x86\Debug\ x86 @@ -53,7 +52,6 @@ TRACE prompt 4 - C:\Users\Mark\AppData\Local\Temp\vs1A55.tmp\x86\Release\ ..\NzbDrone\NzbDrone.ico diff --git a/NzbDrone.Update/Program.cs b/NzbDrone.Update/Program.cs index bb2013924..28246e074 100644 --- a/NzbDrone.Update/Program.cs +++ b/NzbDrone.Update/Program.cs @@ -5,6 +5,7 @@ using NzbDrone.Common; using NzbDrone.Common.Composition; using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Instrumentation; +using NzbDrone.Common.Security; using NzbDrone.Update.UpdateEngine; namespace NzbDrone.Update @@ -28,6 +29,9 @@ namespace NzbDrone.Update try { Console.WriteLine("Starting NzbDrone Update Client"); + + IgnoreCertErrorPolicy.Register(); + GlobalExceptionHandlers.Register(); new LogglyTarget().Register(LogLevel.Debug); diff --git a/NzbDrone.ncrunchsolution b/NzbDrone.ncrunchsolution index 6cb47a29a..444b34b1d 100644 --- a/NzbDrone.ncrunchsolution +++ b/NzbDrone.ncrunchsolution @@ -2,6 +2,7 @@ 1 False true + true UseDynamicAnalysis Disabled Disabled diff --git a/NzbDrone/AppMain.cs b/NzbDrone/AppMain.cs index 20122e9df..6567a229c 100644 --- a/NzbDrone/AppMain.cs +++ b/NzbDrone/AppMain.cs @@ -2,8 +2,8 @@ using System.Diagnostics; using System.Reflection; using NLog; -using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Instrumentation; +using NzbDrone.Common.Security; using NzbDrone.Core.Datastore; namespace NzbDrone @@ -18,6 +18,7 @@ namespace NzbDrone try { GlobalExceptionHandlers.Register(); + IgnoreCertErrorPolicy.Register(); new LogglyTarget().Register(LogLevel.Warn);