I receive the following message when i try to start my service on linux Unable to configure HTTPS endpoint. No server certificate was specified
My WebAPI was created in C# on dotnet 8.0 but when i publish then on linux and try to run the service dll i received the message
fail: Microsoft.Extensions.Hosting.Internal.Host[11]
Hosting failed to start
System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and
To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS o
For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action`1 con
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindConte
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(ListenOptions[] listenOptions, Add
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 applicati
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__15_1(IHostedService service, CancellationToken tok
at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token
My application is not configurated to use a docker or anything related, it just a simple webapi published direct on a linux machine
My NGINX server is configurated with SSL and certificate and others APIs runs fine (All using a older dotnet framework) the server machine using linux Cent OS 7
I dont know if i miss something on appsettings.json or something that i need to do first on my development environment before publish on my server
I try to find other answers here but i only find something related with development environment, my machine works fine with https only on server side that i cannot start the application
Try configure kestrel in you application config file. By example add section:
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://localhost:5000"
},
"Https": {
"Url": "https://0.0.0.0:5001"
}
},
"Certificates":{
"Default":{
"Path":"./cert.pfx",
"Password":""
}
}
}
If need only http remove https section and certificates section. But, i think, it work only if kestrel not configured hardest in code. Also, consider article https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel/endpoints?view=aspnetcore-8.0#configure-endpoints-in-appsettingsjson