diff options
| author | Steve Hayles <stevehayles@gmail.com> | 2019-10-31 18:48:34 +0000 |
|---|---|---|
| committer | Steve Hayles <stevehayles@gmail.com> | 2019-10-31 18:48:34 +0000 |
| commit | da9a59de1e0837d2a4b030d59fa8d009b4457439 (patch) | |
| tree | 5e85c531960a9cb1bce67cfc7b1fcd38746d7b57 /Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs | |
| parent | ef623f512903624bba48f243e3a659ec46064054 (diff) | |
Allow valid https requests in .NET Core
ServerCertificateValidationCallback on the ServicePointManager is not supported in .NET Core and outgoing https requests will fail if the certificate is not trusted.
This adds the equivalent functionality
Diffstat (limited to 'Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs')
| -rw-r--r-- | Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs index 0e6083773..c46503090 100644 --- a/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs +++ b/Emby.Server.Implementations/HttpClientManager/HttpClientManager.cs @@ -59,7 +59,17 @@ namespace Emby.Server.Implementations.HttpClientManager if (!_httpClients.TryGetValue(key, out var client)) { - client = new HttpClient() + var httpClientHandler = new HttpClientHandler() + { + ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => + { + var success = errors == System.Net.Security.SslPolicyErrors.None; + _logger.LogDebug("Validating certificate {Cert}. Success {1}", cert, success); + return success; + } + }; + + client = new HttpClient(httpClientHandler) { BaseAddress = new Uri(url) }; |
