I'm running Docker Desktop on Windows but using Linux containers. I'm trying to set up HTTPS in an ASP.NET Core 8 application, but getting SSL authentication failures. The certificate is generated on Windows and mounted into the Linux container.
Environment
- Host OS: Windows
- Docker Desktop running Linux containers
- ASP.NET Core 8
- Certificate generated using
dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p VerySecurePassword123@!
->dotnet dev-certs https --trust
Error
dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[39]2024-11-14T02:09:35.774407159Z Connection id "0HN84A5GB7LGC" accepted.2024-11-14T02:09:35.774414059Z dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[1]2024-11-14T02:09:35.774430660Z Connection id "0HN84A5GB7LGC" started.2024-11-14T02:09:35.776304532Z dbug: Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionMiddleware[1]2024-11-14T02:09:35.776340833Z Failed to authenticate HTTPS connection.2024-11-14T02:09:35.776346834Z System.Security.Authentication.AuthenticationException: Cannot determine the frame size or a corrupted frame was received.2024-11-14T02:09:35.776350934Z at System.Net.Security.SslStream.GetFrameSize(ReadOnlySpan`1 buffer)2024-11-14T02:09:35.776354134Z at System.Net.Security.SslStream.EnsureFullTlsFrameAsync[TIOAdapter](CancellationToken cancellationToken, Int32 estimatedSize)2024-11-14T02:09:35.776357734Z at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)2024-11-14T02:09:35.776362534Z at System.Net.Security.SslStream.ReceiveHandshakeFrameAsync[TIOAdapter](CancellationToken cancellationToken)2024-11-14T02:09:35.776365734Z at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](Boolean receiveFirst, Byte[] reAuthenticationData, CancellationToken cancellationToken)2024-11-14T02:09:35.776369135Z at System.Net.Security.SslStream.ProcessAuthenticationWithTelemetryAsync(Boolean isAsync, CancellationToken cancellationToken)2024-11-14T02:09:35.776373135Z at Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionMiddleware.OnConnectionAsync(ConnectionContext context)2024-11-14T02:09:35.776377135Z dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[2]2024-11-14T02:09:35.776381235Z Connection id "0HN84A5GB7LGC" stopped.2024-11-14T02:09:35.776534441Z dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[7]2024-11-14T02:09:35.776547141Z Connection id "0HN84A5GB7LGC" sending FIN because: "The Socket transport's send loop completed gracefully."
How can I resolve this? I just need to run this using HTTPS for development purposes to test if a nuget package works on Linux. The certificate type doesn't matter or whether it’s password-protected or passwordless.
Configuration
docker-compose.yml
services: pr.orderservice.webapi: image: pr.orderservice.webapi build: context: . dockerfile: OrderService/PR.OrderService.WebApi/Dockerfile environment: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_URLS=https://+:443;http://+:80 - ASPNETCORE_Kestrel__Certificates__Default__Password=VerySecurePassword123@! - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx ports: - "5000:80" - "44362:443" volumes: - ${USERPROFILE}\.aspnet\https:/https/:ro
Dockerfile
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS baseUSER $APP_UIDWORKDIR /appEXPOSE 8080EXPOSE 8081FROM mcr.microsoft.com/dotnet/sdk:8.0 AS buildARG BUILD_CONFIGURATION=ReleaseWORKDIR /srcCOPY ["OrderService/PR.OrderService.WebApi/PR.OrderService.WebApi.csproj", "OrderService/PR.OrderService.WebApi/"]COPY ["BuildingBlocks/PR.BuildingBlocks.EventBus/PR.BuildingBlocks.EventBus.csproj", "BuildingBlocks/PR.BuildingBlocks.EventBus/"]COPY ["BuildingBlocks/PR.BuildingBlocks.Common/PR.BuildingBlocks.Common.csproj", "BuildingBlocks/PR.BuildingBlocks.Common/"]COPY ["BuildingBlocks/PR.BuildingBlocks.Testing/PR.BuildingBlocks.Testing.csproj", "BuildingBlocks/PR.BuildingBlocks.Testing/"]COPY ["BuildingBlocks/PR.BuildingBlocks.WebCommon/PR.BuildingBlocks.WebCommon.csproj", "BuildingBlocks/PR.BuildingBlocks.WebCommon/"]COPY ["BuildingBlocks/PR.BuildingBlocks.CustomExceptions/PR.BuildingBlocks.CustomExceptions.csproj", "BuildingBlocks/PR.BuildingBlocks.CustomExceptions/"]COPY ["BuildingBlocks/PR.MultiTenancyServer.AspNetCore/PR.MultiTenancyServer.AspNetCore.csproj", "BuildingBlocks/PR.MultiTenancyServer.AspNetCore/"]COPY ["BuildingBlocks/PR.MultiTenancyServer.Core/PR.MultiTenancyServer.Core.csproj", "BuildingBlocks/PR.MultiTenancyServer.Core/"]COPY ["OrderService/PR.OrderService.Persistence.Database/PR.OrderService.Persistence.Database.csproj", "OrderService/PR.OrderService.Persistence.Database/"]COPY ["BuildingBlocks/PR.MultiTenancyServer.EFCore/PR.MultiTenancyServer.EFCore.csproj", "BuildingBlocks/PR.MultiTenancyServer.EFCore/"]COPY ["BuildingBlocks/PR.MultiTenancyServer.Stores/PR.MultiTenancyServer.Stores.csproj", "BuildingBlocks/PR.MultiTenancyServer.Stores/"]COPY ["OrderService/PR.OrderService.Domain/PR.OrderService.Domain.csproj", "OrderService/PR.OrderService.Domain/"]COPY ["OrderService/PR.OrderService.Common/PR.OrderService.Common.csproj", "OrderService/PR.OrderService.Common/"]COPY ["OrderService/PR.OrderService.Persistence/PR.OrderService.Persistence.csproj", "OrderService/PR.OrderService.Persistence/"]COPY ["OrderService/PR.OrderService.Services.Resilience/PR.OrderService.Services.Resilience.csproj", "OrderService/PR.OrderService.Services.Resilience/"]COPY ["OrderService/PR.OrderService.Services/PR.OrderService.Services.csproj", "OrderService/PR.OrderService.Services/"]COPY ["BuildingBlocks/PR.IntegrationEvents.Commons/PR.IntegrationEvents.Commons.csproj", "BuildingBlocks/PR.IntegrationEvents.Commons/"]RUN dotnet restore "OrderService/PR.OrderService.WebApi/PR.OrderService.WebApi.csproj"COPY . .WORKDIR "/src/OrderService/PR.OrderService.WebApi"RUN dotnet build "PR.OrderService.WebApi.csproj" -c $BUILD_CONFIGURATION -o /app/buildFROM build AS publishARG BUILD_CONFIGURATION=ReleaseRUN dotnet publish "PR.OrderService.WebApi.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=falseFROM base AS finalWORKDIR /appCOPY --from=publish /app/publish .ENTRYPOINT ["dotnet", "PR.OrderService.WebApi.dll"]