refactor(http): migrate from HttpClientHandler to SocketsHttpHandler

Update SSL certificate validation approach to use SslClientAuthenticationOptions
with a custom validation callback. This modernizes the HTTP client implementation
while maintaining the same security behavior of accepting all certificates.

BREAKING CHANGE: The underlying HTTP handler implementation has changed from
HttpClientHandler to SocketsHttpHandler, which may affect behavior in edge cases
This commit is contained in:
baliasnyifeliks 2026-01-14 12:58:57 +02:00
parent 1525e163dd
commit 0c06d065d5

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Security;
using System.Security.Authentication;
using System.Text.Json;
using System.Text.RegularExpressions;
@ -259,15 +260,17 @@ namespace UAKino
private async Task<string> GetString(string url, List<HeadersModel> headers, int timeoutSeconds = 15)
{
var handler = new HttpClientHandler
var handler = new SocketsHttpHandler
{
AllowAutoRedirect = true,
AutomaticDecompression = DecompressionMethods.Brotli | DecompressionMethods.GZip | DecompressionMethods.Deflate,
SslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13
SslOptions = new SslClientAuthenticationOptions
{
RemoteCertificateValidationCallback = (_, _, _, _) => true,
EnabledSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13
}
};
handler.ServerCertificateCustomValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
var proxy = _proxyManager.Get();
if (proxy != null)
{