Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

HTTPS redirection never turns on

Abierto Apto para principiantes
#2,694 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
csharp
Área
backend

Línea de trabajo

Lee src/Exceptionless.Web/Program.cs alrededor de las líneas 271–275 y comprueba cómo está configurada la redirección a HTTPS en relación con UseForwardedHeaders() y RunAsync(). El issue sugiere eliminar la comprobación de la dirección enlazada fuera de Development; inspecciona las opciones existentes y el comportamiento del middleware antes de elegir ese cambio. Se considera terminado cuando las solicitudes HTTP se redirigen a HTTPS si hay un endpoint HTTPS configurado, mientras que las solicitudes que ya se reconocen como HTTPS no se redirigen.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug

Program.cs decides whether to add UseHttpsRedirection() by checking the server's bound addresses while the pipeline is being built. Kestrel only fills in those addresses when the app starts, so the list is always empty at that point and the middleware is never added.

Where

src/Exceptionless.Web/Program.cs L271-L275:

var serverAddressesFeature = app.Services.GetRequiredService<IServer>().Features.Get<IServerAddressesFeature>();
bool ssl = options.AppMode != AppMode.Development && serverAddressesFeature is not null && serverAddressesFeature.Addresses.Any(a => a.StartsWith("https://"));

if (ssl)
    app.UseHttpsRedirection();

This runs before app.RunAsync().

What happens

A self-hosted instance listening on both HTTP and HTTPS (for example ASPNETCORE_URLS=http://+:8080;https://+:8443 with a certificate) serves plain HTTP on the HTTP port with no redirect. Setting an HTTPS port (EX_HTTPS_PORT) has no effect.

A minimal ASP.NET Core 10 app shows the timing:

var app = WebApplication.CreateBuilder(args).Build();
var f = app.Services.GetRequiredService<IServer>().Features.Get<IServerAddressesFeature>()!;
Console.WriteLine($"Before start: [{string.Join(",", f.Addresses)}]");
await app.StartAsync();
Console.WriteLine($"After start: [{string.Join(",", f.Addresses)}]");

With ASPNETCORE_URLS=http://127.0.0.1:59123 this prints Before start: [] and After start: [http://127.0.0.1:59123].

Expected

When the server has an HTTPS endpoint outside Development, HTTP requests are redirected to HTTPS.

Suggested fix

Add app.UseHttpsRedirection() outside Development without the address check. The middleware resolves the HTTPS port lazily on the first request (from HttpsRedirectionOptions.HttpsPort, the HTTPS_PORT setting, or the bound addresses) and does nothing, with a single warning, when there is no HTTPS endpoint. It runs after UseForwardedHeaders(), so requests that arrive over HTTPS at a trusted proxy are not redirected. If redirection should stay opt-in, gate it on a config value instead (for example the existing EnableSsl option) rather than on bound addresses.

Lenguaje dominante
C#
Estrellas
2.5k
Forks
508
Merge medio
2 d 17 h
PR fusionados (30 d)
40

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de exceptionless/Exceptionless

Todos los issues de exceptionless/Exceptionless

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.