Warm tip: This article is reproduced from serverfault.com, please click

dotnet 5 CLI doesn't give https on centos 8

发布于 2020-11-30 17:35:58

I cannot get https to start on a centos 8 box using a 'framework dependant' published site. Both have the same version of the dotnet runtime 5.0.100

When I run the command dotnet run project.dll on windows I get :

info: Microsoft.Hosting.Lifetime[0]
       Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
      Now listening on: https://localhost:5001
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production

When I run the same project on Centos 8 I only get

info: Microsoft.Hosting.Lifetime[0]
      Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production

Am I missing something?

Questioner
Marc C
Viewed
0
Marc C 2020-12-04 02:42:30

So it turns out that .net 3.1/5 will look for a local development certificate here: /home/{user name} /.dotnet/corefx/cryptography/x509stores/my

It will not load https if this certificate is not present, you can set this up yourself from the appsettings file:

Once you have enabled these settings the application will start on the https settings. E.g.

"Kestrel": {
"Endpoints": {
  "HTTPS": {
    "Url": "https://localhost:5001",
    "Certificate": {
      "Path": "/etc/ssl/certs/<certificate.pfx>",
      "Password": "xyz123"
    }
  }
}}

Answer to this question can be found here : ASP.Net Core application service only listening to Port 5000 on Ubuntu

Microsoft documentation : https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-5.0#endpoint-configuration