mirror of https://github.com/Jackett/Jackett
core: fix ignoresslerrors cli option (#9657)
This commit is contained in:
parent
bbe99c4123
commit
7279edf354
|
@ -63,6 +63,7 @@ namespace Jackett.Common.Models.Config
|
|||
{
|
||||
var options = this;
|
||||
var runtimeSettings = new RuntimeSettings();
|
||||
|
||||
// Logging
|
||||
if (options.Logging)
|
||||
runtimeSettings.LogRequests = true;
|
||||
|
@ -83,11 +84,11 @@ namespace Jackett.Common.Models.Config
|
|||
|
||||
// Use Proxy
|
||||
if (options.ProxyConnection != null)
|
||||
{
|
||||
runtimeSettings.ProxyConnection = options.ProxyConnection.ToLowerInvariant();
|
||||
}
|
||||
|
||||
// Ignore SSL errors on Curl
|
||||
runtimeSettings.IgnoreSslErrors = options.IgnoreSslErrors;
|
||||
|
||||
runtimeSettings.NoRestart = options.NoRestart;
|
||||
runtimeSettings.NoUpdates = options.NoUpdates;
|
||||
|
||||
|
|
|
@ -37,32 +37,27 @@ namespace Jackett.Common.Utils.Clients
|
|||
var request = (HttpWebRequest)sender;
|
||||
var hash = certificate.GetCertHashString();
|
||||
|
||||
|
||||
trustedCertificates.TryGetValue(hash, out var hosts);
|
||||
if (hosts != null)
|
||||
{
|
||||
if (hosts.Contains(request.Host))
|
||||
if (hosts != null && hosts.Contains(request.Host))
|
||||
return true;
|
||||
}
|
||||
|
||||
// Throw exception with certificate details, this will cause a "Exception User-Unhandled" when running it in the Visual Studio debugger.
|
||||
// The certificate is only available inside this function, so we can't catch it at the calling method.
|
||||
if (sslPolicyErrors != SslPolicyErrors.None)
|
||||
{
|
||||
// Throw exception with certificate details, this will cause a "Exception User-Unhandled" when running it in the Visual Studio debugger.
|
||||
// The certificate is only available inside this function, so we can't catch it at the calling method.
|
||||
throw new Exception("certificate validation failed: " + certificate.ToString());
|
||||
}
|
||||
throw new Exception("certificate validation failed: " + certificate);
|
||||
|
||||
return sslPolicyErrors == SslPolicyErrors.None;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
ServicePointManager.DefaultConnectionLimit = 1000;
|
||||
|
||||
base.Init();
|
||||
|
||||
// custom handler for our own internal certificates
|
||||
ServicePointManager.ServerCertificateValidationCallback += ValidateCertificate;
|
||||
if (serverConfig.RuntimeSettings.IgnoreSslErrors == true)
|
||||
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
|
||||
else
|
||||
ServicePointManager.ServerCertificateValidationCallback += ValidateCertificate;
|
||||
}
|
||||
|
||||
protected override async Task<WebResult> Run(WebRequest webRequest)
|
||||
|
|
|
@ -40,20 +40,14 @@ namespace Jackett.Common.Utils.Clients
|
|||
{
|
||||
var hash = certificate.GetCertHashString();
|
||||
|
||||
|
||||
trustedCertificates.TryGetValue(hash, out var hosts);
|
||||
if (hosts != null)
|
||||
{
|
||||
if (hosts.Contains(request.RequestUri.Host))
|
||||
if (hosts != null && hosts.Contains(request.RequestUri.Host))
|
||||
return true;
|
||||
}
|
||||
|
||||
// Throw exception with certificate details, this will cause a "Exception User-Unhandled" when running it in the Visual Studio debugger.
|
||||
// The certificate is only available inside this function, so we can't catch it at the calling method.
|
||||
if (sslPolicyErrors != SslPolicyErrors.None)
|
||||
{
|
||||
// Throw exception with certificate details, this will cause a "Exception User-Unhandled" when running it in the Visual Studio debugger.
|
||||
// The certificate is only available inside this function, so we can't catch it at the calling method.
|
||||
throw new Exception("certificate validation failed: " + certificate.ToString());
|
||||
}
|
||||
throw new Exception("certificate validation failed: " + certificate);
|
||||
|
||||
return sslPolicyErrors == SslPolicyErrors.None;
|
||||
}
|
||||
|
@ -75,7 +69,10 @@ namespace Jackett.Common.Utils.Clients
|
|||
};
|
||||
|
||||
// custom certificate validation handler (netcore version)
|
||||
clientHandlr.ServerCertificateCustomValidationCallback = ValidateCertificate;
|
||||
if (serverConfig.RuntimeSettings.IgnoreSslErrors == true)
|
||||
clientHandlr.ServerCertificateCustomValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;
|
||||
else
|
||||
clientHandlr.ServerCertificateCustomValidationCallback = ValidateCertificate;
|
||||
|
||||
clearanceHandlr.InnerHandler = clientHandlr;
|
||||
client = new HttpClient(clearanceHandlr);
|
||||
|
@ -94,8 +91,6 @@ namespace Jackett.Common.Utils.Clients
|
|||
|
||||
public override void Init()
|
||||
{
|
||||
ServicePointManager.DefaultConnectionLimit = 1000;
|
||||
|
||||
base.Init();
|
||||
|
||||
ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072;
|
||||
|
|
|
@ -193,15 +193,7 @@ namespace Jackett.Common.Utils.Clients
|
|||
protected virtual async Task<WebResult> Run(WebRequest webRequest) => throw new NotImplementedException();
|
||||
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
|
||||
|
||||
public virtual void Init()
|
||||
{
|
||||
if (serverConfig.RuntimeSettings.IgnoreSslErrors == true)
|
||||
{
|
||||
logger.Info($"WebClient({ClientType}): Disabling certificate validation");
|
||||
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => { return true; };
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Init() => ServicePointManager.DefaultConnectionLimit = 1000;
|
||||
|
||||
public virtual void OnCompleted() => throw new NotImplementedException();
|
||||
|
||||
|
|
|
@ -13,35 +13,24 @@ namespace Jackett.Server
|
|||
{
|
||||
if (runtimeSettings.ClientOverride != "httpclient" && runtimeSettings.ClientOverride != "httpclient2")
|
||||
{
|
||||
logger.Error($"Client override ({runtimeSettings.ClientOverride}) has been deprecated, please remove it from your start arguments");
|
||||
logger.Error($"Client override ({runtimeSettings.ClientOverride}) has been deprecated, please remove it from your start arguments.");
|
||||
Environment.Exit(1);
|
||||
}
|
||||
|
||||
if (runtimeSettings.LogRequests)
|
||||
{
|
||||
logger.Info("Logging enabled.");
|
||||
}
|
||||
|
||||
if (runtimeSettings.TracingEnabled)
|
||||
{
|
||||
logger.Info("Tracing enabled.");
|
||||
}
|
||||
|
||||
// https://github.com/Jackett/Jackett/issues/6229
|
||||
//if (runtimeSettings.IgnoreSslErrors == true)
|
||||
//{
|
||||
// logger.Error($"The IgnoreSslErrors option has been deprecated, please remove it from your start arguments");
|
||||
//}
|
||||
if (runtimeSettings.IgnoreSslErrors == true)
|
||||
logger.Info("Ignore SSL errors enabled.");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(runtimeSettings.CustomDataFolder))
|
||||
{
|
||||
logger.Info("Jackett Data will be stored in: " + runtimeSettings.CustomDataFolder);
|
||||
}
|
||||
|
||||
if (runtimeSettings.ProxyConnection != null)
|
||||
{
|
||||
logger.Info("Proxy enabled. " + runtimeSettings.ProxyConnection);
|
||||
}
|
||||
logger.Info("Proxy enabled: " + runtimeSettings.ProxyConnection);
|
||||
}
|
||||
|
||||
public static void ProcessWindowsSpecificArgs(ConsoleOptions consoleOptions, IProcessService processService, ServerConfig serverConfig, Logger logger)
|
||||
|
|
Loading…
Reference in New Issue