C
C#4mo ago
Ares

✅ Unable to configure HTTPS endpoint.

The container builds successfully but then at the end it says:
at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)
Unhandled exception. System.InvalidOperationException: **Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.
To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.**
at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)
Unhandled exception. System.InvalidOperationException: **Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.
To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.**
I tried running
dotnet dev-certs https --clean
sudo dotnet dev-certs https --clean
dotnet dev-certs https
dotnet dev-certs https --trust
dotnet dev-certs https --check --trust
dotnet dev-certs https --clean
sudo dotnet dev-certs https --clean
dotnet dev-certs https
dotnet dev-certs https --trust
dotnet dev-certs https --check --trust
it says that my certificate is valid but it still keeps giving me Unable to configure HTTPS endpoint. I also tried completely removing docker and then adding it back. but that didn twork either. I tried removing app.UseHttpsRedirection(); from Program.cs too. nothing seems to work at all.
7 Replies
Ares
Ares4mo ago
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 5000
EXPOSE 5001

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["realTimePollsApp/realTimePolls.csproj", "realTimePollsApp/"]
RUN dotnet restore "./realTimePollsApp/./realTimePolls.csproj"
COPY . .
WORKDIR "/src/realTimePollsApp"
RUN dotnet build "./realTimePolls.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./realTimePolls.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "realTimePolls.dll"]
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 5000
EXPOSE 5001

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["realTimePollsApp/realTimePolls.csproj", "realTimePollsApp/"]
RUN dotnet restore "./realTimePollsApp/./realTimePolls.csproj"
COPY . .
WORKDIR "/src/realTimePollsApp"
RUN dotnet build "./realTimePolls.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./realTimePolls.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "realTimePolls.dll"]
version: '3.4'

services:
realtimepolls:
image: ${DOCKER_REGISTRY-}realtimepolls
container_name: realtimepolls
build:
context: .
dockerfile: realTimePollsApp/Dockerfile
ports:
- "5000:5000"
- "5001:5001"
realtimepolls.database:
image: postgres:latest
container_name: realtimepolls.database
environment:
- POSTGRES_DB=products
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
volumes:
- ./.realtimepolls_db-data:/var/lib/postgresql/data
ports:
- 5432:5432

version: '3.4'

services:
realtimepolls:
image: ${DOCKER_REGISTRY-}realtimepolls
container_name: realtimepolls
build:
context: .
dockerfile: realTimePollsApp/Dockerfile
ports:
- "5000:5000"
- "5001:5001"
realtimepolls.database:
image: postgres:latest
container_name: realtimepolls.database
environment:
- POSTGRES_DB=products
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
volumes:
- ./.realtimepolls_db-data:/var/lib/postgresql/data
ports:
- 5432:5432

Once again the error is:
Hosting failed to start
System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.
To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
Hosting failed to start
System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.
To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
ive been trying to fix this for an hour i think that something is very wrong
C:\Users\p>dotnet dev-certs https --check
A valid certificate was found: 308030F2AAA3B9E7356546576F9DBE1EAA7A4AC1 - CN=localhost - Valid from 2024-02-29 15:50:07Z to 2025-02-28 15:50:07Z - IsHttpsDevelopmentCertificate: true - IsExportable: true
Run the command with both --check and --trust options to ensure that the certificate is not only valid but also trusted.
C:\Users\p>dotnet dev-certs https --check
A valid certificate was found: 308030F2AAA3B9E7356546576F9DBE1EAA7A4AC1 - CN=localhost - Valid from 2024-02-29 15:50:07Z to 2025-02-28 15:50:07Z - IsHttpsDevelopmentCertificate: true - IsExportable: true
Run the command with both --check and --trust options to ensure that the certificate is not only valid but also trusted.
when i ran the https commands above it says my cert is valid so why? i tried
EXPOSE 443
EXPOSE 8081
EXPOSE 443
EXPOSE 8081
too
Pobiega
Pobiega4mo ago
docker + dev cert = bad idea the dev cert is only for local development, once you are ready to host the API you're looking at providing a real https cert, probably via a reverse proxy
Ares
Ares4mo ago
i dont really understand cause now i am trying to run with IIS express i think that something is wrong. but i didnt do anything out of the ordinary im going to restart my computer and see if that helps
No description
Ares
Ares4mo ago
yeah i dont really understand why its doing this, it builds and runs the image just fine but then after that i see all of this in the console. nothing i tried helped at all
No description
Ares
Ares4mo ago
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"environmentVariables": {
"ASPNETCORE_HTTPS_PORTS": "5001",
"ASPNETCORE_HTTP_PORTS": "5000"
},
"publishAllPorts": true,
"useSSL": false <=== made false
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"environmentVariables": {
"ASPNETCORE_HTTPS_PORTS": "5001",
"ASPNETCORE_HTTP_PORTS": "5000"
},
"publishAllPorts": true,
"useSSL": false <=== made false
}
},
i went to properties/launchoptions and made useSSL false too so im not sure why nvm resolved https://learn.microsoft.com/en-us/aspnet/core/security/docker-compose-https?view=aspnetcore-8.0 i did this and changed to 8080 and 8081 instead of 5000 and 5001
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Ares
Ares4mo ago
my bad i just read this cause i dont get notifications for some reason. i didnt know that though ill stop using iis. and i shouldnt need to use any certs apprently with docker so ill see about tha ttoo