【问题标题】:dotnet 5 CLI doesn't give https on centos 8dotnet 5 CLI 在 centos 8 上不提供 https
【发布时间】:2020-11-30 17:35:58
【问题描述】:

我无法在使用“依赖框架”的已发布站点的 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

我错过了什么吗?

【问题讨论】:

  • 你有什么异常吗?
  • 我不是,或者我什么也说不出来。 dotnet 命令仍然运行成功。
  • 在 Windows 中,您将 HTTP 用于端口 5000,将 HTTPS 用于端口 5001。因此,在 Centos 8 中,您似乎无法通过 https(安全)。 HTTPS 使用 TLS 进行身份验证,需要证书并支持 TLS 1.2/1.3(1.0/1.1 不再有效)。所以我会阅读以下内容:linuxconfig.org/how-to-install-mod-ssl-on-redhat-8
  • @jdweng 我很感谢你的 cmets,我会读一读,尽管当降级到 .net 3.1 时,我可以在 centos 8 上托管 5000 和 (https) 5001
  • Windows 正在运行,因此您必须在 Centos 8 中使用相同的版本。如果您使用嗅探器,您应该会看到 TLS 版本,通常是 1.2 和 windows,然后让 centos 以相同的模式工作。我有可能您正在运行 1.3。

标签: c# .net-core centos


【解决方案1】:

原来.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 application service only listening to Port 5000 on Ubuntu

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

【讨论】:

    猜你喜欢
    • 2016-08-14
    • 2020-08-22
    • 2021-06-09
    • 2021-11-03
    • 2015-03-13
    • 1970-01-01
    • 1970-01-01
    • 2021-09-23
    • 2016-08-10
    相关资源
    最近更新 更多