Check for BTLS support before using it

This commit is contained in:
kaso17 2017-03-07 11:50:50 +01:00
parent 670a3a78af
commit 4823e61015
1 changed files with 21 additions and 1 deletions

View File

@ -55,7 +55,27 @@ namespace Jackett
var monoVersionO = new Version(monoVersion.Split(' ')[0]);
if (monoVersionO.Major >= 4 && monoVersionO.Minor >= 8)
{
usehttpclient = true;
// check if btls is supported
var monoSecurity = Assembly.Load("Mono.Security");
Type monoTlsProviderFactory = monoSecurity.GetType("Mono.Security.Interface.MonoTlsProviderFactory");
if (monoTlsProviderFactory != null)
{
MethodInfo isProviderSupported = monoTlsProviderFactory.GetMethod("IsProviderSupported");
if(isProviderSupported != null)
{
var btlsSupported = (bool)isProviderSupported.Invoke(null, new string[] { "btls" });
if (btlsSupported)
{
// initialize btls
MethodInfo initialize = monoTlsProviderFactory.GetMethod("Initialize", new[] { typeof(string) });
if (initialize != null)
{
initialize.Invoke(null, new string[] { "btls" });
usehttpclient = true;
}
}
}
}
}
}
}