dotnet 5 CLI 不在 centos 8 上提供 https

dotnet 5 CLI doesn't give https on centos 8

我无法使用 'framework dependant' 发布的站点在 centos 8 机器上启动 https。 两者都有相同版本的 dotnet runtime 5.0.100

当我在 windows 上 运行 命令 dotnet run project.dll 时,我得到:

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

当我在 Centos 8 上 运行 同一个项目时,我只得到

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

我是不是漏掉了什么?

原来.net 3.1/5会在这里寻找本地开发证书: /home/{user name} /.dotnet/corefx/cryptography/x509stores/my

如果此证书不存在,它将不会加载 https,您可以从 appsettings 文件中自行设置:

启用这些设置后,应用程序将在 https 设置上启动。例如

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

可以在此处找到此问题的答案:

微软文档: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-5.0#endpoint-configuration