Fix 0946
This commit is contained in:
		| @@ -40,34 +40,41 @@ builder.Services.AddHttpClient("ElectoralApiClient", client => | ||||
|         client.BaseAddress = new Uri(baseUrl); | ||||
|     } | ||||
|  | ||||
|     // Limpiamos headers por defecto y añadimos uno que simula ser un navegador moderno. | ||||
|     // Esto es crucial para pasar a través de WAFs (Web Application Firewalls). | ||||
|     // Limpiamos los headers por defecto y añadimos uno que simula ser un navegador. | ||||
|     // Esto es crucial para pasar a través de Firewalls de Aplicaciones Web (WAFs) | ||||
|     // que bloquean clientes automatizados no reconocidos. | ||||
|     client.DefaultRequestHeaders.Clear(); | ||||
|     client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"); | ||||
|     client.DefaultRequestHeaders.Add("Accept", "*/*"); // Opcional, pero ayuda a parecerse más a Postman/navegador | ||||
|     client.DefaultRequestHeaders.Add("Accept-Encoding", "gzip, deflate, br"); // Opcional | ||||
|     client.DefaultRequestHeaders.Add("Connection", "keep-alive"); // Opcional | ||||
|  | ||||
| }) | ||||
| .ConfigurePrimaryHttpMessageHandler(() => | ||||
| { | ||||
|     return new SocketsHttpHandler | ||||
|     var handler = new SocketsHttpHandler | ||||
|     { | ||||
|         SslOptions = new SslClientAuthenticationOptions | ||||
|         { | ||||
|             // Forzamos el protocolo TLS 1.3 | ||||
|             EnabledSslProtocols = SslProtocols.Tls13, | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|             // --- ¡¡¡LA LÍNEA CLAVE CORREGIDA!!! --- | ||||
|             // Forzamos explícitamente los únicos 3 cipher suites que el servidor acepta. | ||||
|             CipherSuitesPolicy = new CipherSuitesPolicy(new[] | ||||
|     if (!OperatingSystem.IsWindows()) | ||||
|     { | ||||
|         handler.SslOptions.CipherSuitesPolicy = new CipherSuitesPolicy(new[] | ||||
|         { | ||||
|             TlsCipherSuite.TLS_AES_128_GCM_SHA256, | ||||
|             TlsCipherSuite.TLS_AES_256_GCM_SHA384, | ||||
|             TlsCipherSuite.TLS_CHACHA20_POLY1305_SHA256 | ||||
|             }) | ||||
|         }); | ||||
|     } | ||||
|     }; | ||||
|  | ||||
|     return handler; | ||||
| }); | ||||
|  | ||||
| builder.Services.AddSingleton<IElectoralApiService, ElectoralApiService>(); | ||||
| // --- FIN DE LA SECCIÓN MODIFICADA --- | ||||
|  | ||||
| #endif | ||||
|  | ||||
| builder.Services.AddHostedService<Worker>(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user