Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker images: Unable to configure HTTPS endpoint #85

Open
D4sh12 opened this issue Apr 23, 2024 · 8 comments
Open

Docker images: Unable to configure HTTPS endpoint #85

D4sh12 opened this issue Apr 23, 2024 · 8 comments

Comments

@D4sh12
Copy link

D4sh12 commented Apr 23, 2024

Following the README file, everything works fine, but the main services like catalog, ordering, basket, etc., didn't worked due to HTTPS config exception.
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'.

Docker log Terminal:

2024-04-23 13:35:41 info: Marten.Services.MartenActivator[0]
2024-04-23 13:35:41       Applying initial data Catalog.API.Data.CatalogInitialData
2024-04-23 13:35:43 fail: Microsoft.Extensions.Hosting.Internal.Host[11]
2024-04-23 13:35:43       Hosting failed to start
2024-04-23 13:35:43       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.
2024-04-23 13:35:43       To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
2024-04-23 13:35:43       For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
2024-04-23 13:35:43          at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action`1 configureOptions)
2024-04-23 13:35:43          at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context, CancellationToken cancellationToken)
2024-04-23 13:35:43          at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(ListenOptions[] listenOptions, AddressBindContext context, Func`2 useHttps, CancellationToken cancellationToken)
2024-04-23 13:35:43          at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)
2024-04-23 13:35:43          at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
2024-04-23 13:35:43          at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
2024-04-23 13:35:43          at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__15_1(IHostedService service, CancellationToken token)
2024-04-23 13:35:43          at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)
2024-04-23 13:35:43 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.
2024-04-23 13:35:43 To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
2024-04-23 13:35:43 For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
2024-04-23 13:35:43    at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action`1 configureOptions)
2024-04-23 13:35:43    at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context, CancellationToken cancellationToken)
2024-04-23 13:35:43    at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(ListenOptions[] listenOptions, AddressBindContext context, Func`2 useHttps, CancellationToken cancellationToken)
2024-04-23 13:35:43    at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)
2024-04-23 13:35:43    at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
2024-04-23 13:35:43    at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
2024-04-23 13:35:43    at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__15_1(IHostedService service, CancellationToken token)
2024-04-23 13:35:43    at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)
2024-04-23 13:35:43    at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
2024-04-23 13:35:43    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
2024-04-23 13:35:43    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
2024-04-23 13:35:43    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
2024-04-23 13:35:43    at Program.<Main>$(String[] args) in /src/Services/Catalog/Catalog.API/Program.cs:line 44

Any ideas?

@mbehnasr
Copy link

mbehnasr commented May 18, 2024

I have same problem and I don't how fix that
my os is ubuntu22

@JuliusKoronciCH
Copy link

JuliusKoronciCH commented May 18, 2024

this is a massive pain based on chatgpt the kestrel certificate and password need to be an env var I tried on my mac and also on windows

@BardiaYaghmaie
Copy link

this should be fixed

@JuliusKoronciCH
Copy link

let me pull again but I checked out the repo 2 days ago and I dont see any commits since

@JuliusKoronciCH
Copy link

@BardiaYaghmaie after some tinkering this works when running from visual studio as it does some additional magic but running docker-compose -f docker-compose.yml -f docker-compose.override.yml up -d is missing a few things so I would recommend updating the docker compose overrides and the documentation ..like the hardcoded windows paths and the fact that rider or just VS Code are not an option make it hard to use ..I had to switch from my mac to my windows machine to get it working

@mbehnasr
Copy link

Did you find any solution regarding the volumes set in docker-compose.override? I can't find 'usersecrets' and 'Https'. I can't find these two.

@JuliusKoronciCH
Copy link

@mbehnasr for db services I had to add
- POSTGRES_HOST_AUTH_METHOD=trust

  for the volumes on my mac its
    volumes:
  - ~/.microsoft/usersecrets:/home/app/.microsoft/usersecrets:ro
  - ~/.microsoft/devcerts:/home/app/.aspnet/https:ro
  
  but ask AI it helps
  
  this will still not solve the issues with https follow this article: https://learn.microsoft.com/en-us/aspnet/core/security/docker-https?view=aspnetcore-8.0 

@JuliusKoronciCH
Copy link

this one worked for me and the diff is that visual studio configure and runs with the correct certs while otherwise you need to generate your certs with a password amd mount the location and also tell dotnet where to find them and whats the password
dotnet dev-certs https -ep ./certs/aspnetapp.pfx -p SuperSecretPassword

shopping.web:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_HTTP_PORTS=8080
- ASPNETCORE_HTTPS_PORTS=8081
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx
- ASPNETCORE_Kestrel__Certificates__Default__Password=SuperSecretPassword
- ApiSettings__GatewayAddress=http://yarpapigateway:8080
depends_on:
- yarpapigateway
ports:
- "6005:8080"
- "6065:8081"
volumes:
- ./certs:/https/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants