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

c#-dotnet 5 CLI在centos 8上不提供https

(c# - dotnet 5 CLI doesn't give https on centos 8)

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

我无法使用“依赖于框架”的发布站点使https从centos 8框开始。两者具有相同的版本dotnet runtime 5.0.100

当我dotnet run project.dllWindows运行命令时我得到:

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

我想念什么吗?

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

因此,事实证明.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"
    }
  }
}}

可以在这里找到该问题的答案: ASP.Net Core应用程序服务仅在Ubuntu上侦听Port 5000

Microsoft文档:https : //docs.microsoft.com/zh-cn/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-5.0#endpoint-configuration