Home > Software design >  Do I require HttpsRedirection?
Do I require HttpsRedirection?

Time:01-17

"Kestrel": {
    "Endpoints": {
      "Https": {
        "Url": "https://*:443",
        "Protocols": "Http1"
      },
      "gRPC": {
        "Url": "https://*:8443",
        "Protocols": "Http2"
      }
    }

I am using the above kestrel configuration to run my ASP.NET Core Web API app. I have the required Self signed development certificate for development purposes and the CA certificate configuration for Server deployments.

My application is not public facing and I can configure the clients to the APIs over SSL. So, As seen above, I am not exposing an HTTP endpoint.

Do I require UseHttpsRedirection or ASPNETCORE_HTTPS_PORT configuration as I am not exposing a non-secure Http port?

CodePudding user response:

There's no need for UseHttpsRedirection in this scenario, where Kestrel listens only on https. The first step in the HttpsRedirectionMiddleware is to check whether the established connection is already on https: if it is, the middleware does nothing (it's a no-op):

if (context.Request.IsHttps)
{
    return _next(context);
}
  • Related