aspnetrun / run-aspnetcore-microservices

Microservices on .Net platforms which used ASP.NET Web API, Docker, RabbitMQ, MassTransit, Grpc, Yarp API Gateway, PostgreSQL, Redis, SQLite, SqlServer, Marten, Entity Framework Core, CQRS, MediatR, DDD, Vertical and Clean Architecture implementation with using latest features of .NET 8 and C# 12
https://www.udemy.com/course/microservices-architecture-and-implementation-on-dotnet/?couponCode=JUNE24
MIT License
2.53k stars 1.38k forks source link

Docker images: Unable to configure HTTPS endpoint #85

Open D4sh12 opened 2 months ago

D4sh12 commented 2 months ago

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 commented 1 month ago

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

JuliusKoronciCH commented 1 month ago

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 commented 1 month ago

this should be fixed

JuliusKoronciCH commented 1 month ago

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

JuliusKoronciCH commented 1 month ago

@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 commented 1 month ago

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 commented 1 month ago

@mbehnasr for db services I had to add

JuliusKoronciCH commented 1 month ago

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: