【问题标题】:Why does Kestrel fail to start when certificates are present?为什么存在证书时 Kestrel 无法启动?
【发布时间】:2020-04-30 13:18:33
【问题描述】:

我在 Windows Server 2019 上使用 Apache 2.4 作为 Kestrel 的反向代理。我有一个应用程序已经在服务器上运行。我在C:\Apache24\conf\sites-enabled 中使用自己的appname.conf 文件设置了第二个应用程序,并将新的、未过期的SSL 证书文件添加到C:\Apache24\conf\ssl\appname

在应用程序的Program.cs 中,这是CreateHostBuilder,我在其中指定了要使用的端口,因此它们与第一个应用程序的不同:

public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseUrls("http://localhost:5002", "https://localhost:5003");
                webBuilder.UseStartup<Startup>();
            });

在服务器 (dotnet appname.dll) 上运行命令启动应用程序时,我收到此错误:

暴击:Microsoft.AspNetCore.Server.Kestrel[0] 无法启动 Kestrel。 System.InvalidOperationException:无法配置 HTTPS 端点。未指定服务器证书,默认开发者证书找不到或已过期。

要生成开发人员证书,请运行“dotnet dev-certs https”。要信任证书(仅限 Windows 和 macOS),请运行“dotnet dev-certs https --trust”。 有关配置 HTTPS 的更多信息,请参阅https://go.microsoft.com/fwlink/?linkid=848054

即使我有真正的 SSL 证书,我已经运行 dotnet dev-certs https --trust,正如错误所暗示的那样,甚至首先从 Windows 证书管理器 GUI 中删除证书,正如建议的 on Github 那样,无济于事.

非常感谢任何帮助。

【问题讨论】:

标签: windows apache asp.net-core ssl-certificate kestrel


【解决方案1】:

正如 Lex Li 在 cmets 中所指出的,UseUrls() 不需要 URL 的 https 版本。要在同一台服务器上拥有其他应用程序,只需向 Kestrel 提供一个未使用的端口,这就是它的完成方式。以下是CreateHostBuilder 的外观:

public static IHostBuilder CreateHostBuilder(string[] args) =>
    Host.CreateDefaultBuilder(args)
        .ConfigureWebHostDefaults(webBuilder =>
        {
            webBuilder.UseUrls("http://localhost:5002");
            webBuilder.UseStartup<Startup>();
        });

【讨论】:

    猜你喜欢
    • 2021-07-05
    • 1970-01-01
    • 2020-04-20
    • 2022-01-07
    • 2021-12-12
    • 2012-03-01
    • 2021-02-04
    • 2023-03-23
    • 2020-10-29
    相关资源
    最近更新 更多