mirror of
https://github.com/Jackett/Jackett
synced 2025-03-10 06:03:09 +00:00
This reverts commit 4a11a770d7
.
This commit is contained in:
parent
db0d14822f
commit
263b5b5433
2 changed files with 17 additions and 9 deletions
|
@ -26,15 +26,19 @@ namespace Jackett.Common.Utils.Clients
|
|||
protected static IWebProxy webProxy;
|
||||
|
||||
[DebuggerNonUserCode] // avoid "Exception User-Unhandled" Visual Studio messages
|
||||
public static bool ValidateCertificate(HttpRequestMessage request, X509Certificate2 certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
|
||||
public static bool ValidateCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
|
||||
{
|
||||
if (sender.GetType() != typeof(HttpWebRequest))
|
||||
return sslPolicyErrors == SslPolicyErrors.None;
|
||||
|
||||
var request = (HttpWebRequest)sender;
|
||||
var hash = certificate.GetCertHashString();
|
||||
|
||||
|
||||
trustedCertificates.TryGetValue(hash, out var hosts);
|
||||
if (hosts != null)
|
||||
{
|
||||
if (hosts.Contains(request.RequestUri.Host))
|
||||
if (hosts.Contains(request.Host))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -121,6 +125,8 @@ namespace Jackett.Common.Utils.Clients
|
|||
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => { return true; };
|
||||
}
|
||||
|
||||
// custom handler for our own internal certificates
|
||||
ServicePointManager.ServerCertificateValidationCallback += ValidateCertificate;
|
||||
}
|
||||
|
||||
protected override async Task<WebClientByteResult> Run(WebRequest webRequest)
|
||||
|
@ -153,8 +159,6 @@ namespace Jackett.Common.Utils.Clients
|
|||
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
|
||||
})
|
||||
{
|
||||
// custom certificate validation handler (netcore version)
|
||||
clientHandlr.ServerCertificateCustomValidationCallback = ValidateCertificate;
|
||||
clearanceHandlr.InnerHandler = clientHandlr;
|
||||
using (var client = new HttpClient(clearanceHandlr))
|
||||
{
|
||||
|
|
|
@ -33,15 +33,19 @@ namespace Jackett.Common.Utils.Clients
|
|||
protected static IWebProxy webProxy;
|
||||
|
||||
[DebuggerNonUserCode] // avoid "Exception User-Unhandled" Visual Studio messages
|
||||
public static bool ValidateCertificate(HttpRequestMessage request, X509Certificate2 certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
|
||||
public static bool ValidateCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
|
||||
{
|
||||
if (sender.GetType() != typeof(HttpWebRequest))
|
||||
return sslPolicyErrors == SslPolicyErrors.None;
|
||||
|
||||
var request = (HttpWebRequest)sender;
|
||||
var hash = certificate.GetCertHashString();
|
||||
|
||||
|
||||
trustedCertificates.TryGetValue(hash, out var hosts);
|
||||
if (hosts != null)
|
||||
{
|
||||
if (hosts.Contains(request.RequestUri.Host))
|
||||
if (hosts.Contains(request.Host))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -129,9 +133,6 @@ namespace Jackett.Common.Utils.Clients
|
|||
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
|
||||
};
|
||||
|
||||
// custom certificate validation handler (netcore version)
|
||||
clientHandlr.ServerCertificateCustomValidationCallback = ValidateCertificate;
|
||||
|
||||
clearanceHandlr.InnerHandler = clientHandlr;
|
||||
client = new HttpClient(clearanceHandlr);
|
||||
}
|
||||
|
@ -159,6 +160,9 @@ namespace Jackett.Common.Utils.Clients
|
|||
}
|
||||
|
||||
ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072;
|
||||
|
||||
// custom handler for our own internal certificates
|
||||
ServicePointManager.ServerCertificateValidationCallback += ValidateCertificate;
|
||||
}
|
||||
|
||||
protected override async Task<WebClientByteResult> Run(WebRequest webRequest)
|
||||
|
|
Loading…
Add table
Reference in a new issue