Fixed: Added fallback and log errors when Tls1.2 clashes with https certificate with obsolete md5 hash.

This commit is contained in:
Taloth Saldono
2016-09-13 22:57:07 +02:00
parent 713e109bc9
commit 816cf608fc
5 changed files with 40 additions and 7 deletions
@@ -24,6 +24,7 @@ namespace NzbDrone.Common.Security
protocol |= Tls11;
}
// Enabling Tls1.2 invalidates certificates using md5, so we disable Tls12 on the fly if that happens.
if (Enum.IsDefined(typeof(SecurityProtocolType), Tls12))
{
protocol |= Tls12;
@@ -36,5 +37,23 @@ namespace NzbDrone.Common.Security
Logger.Debug(ex, "Failed to set TLS security protocol.");
}
}
public static void DisableTls12()
{
try
{
var protocol = ServicePointManager.SecurityProtocol;
if (protocol.HasFlag(Tls12))
{
Logger.Warn("Disabled Tls1.2 due to remote certificate error.");
ServicePointManager.SecurityProtocol = protocol & ~Tls12;
}
}
catch (Exception ex)
{
Logger.Debug(ex, "Failed to disable TLS 1.2 security protocol.");
}
}
}
}