4

更新: 刚刚尝试了官方示例https://github.com/aspnet/AspNetCore.Docs/tree/master/aspnetcore/fundamentals/servers/httpsys/samples/3.x/SampleApp并且它不起作用。

浏览器消息:

This site can’t provide a secure connection
localhost sent an invalid response.

输出:

信息:Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
      用户配置文件可用。使用“C:\Users\xxx\AppData\Local\ASP.NET\DataProtection-Keys”作为密钥存储库和 Windows DPAPI 来加密静态密钥。
警告:Microsoft.AspNetCore.Server.HttpSys.MessagePump[0]
      覆盖地址“https://localhost:5001, http://localhost:5000”。绑定到添加到 UrlPrefixes 的端点。
信息:Microsoft.AspNetCore.Server.HttpSys.HttpSysListener[0]
      开始
信息:Microsoft.AspNetCore.Server.HttpSys.HttpSysListener[0]
      监听前缀:http://localhost:5005/
信息:Microsoft.Hosting.Lifetime[0]
      现在收听:http://localhost:5005/
信息:Microsoft.Hosting.Lifetime[0]
      申请开始。按 Ctrl+C 关闭。
信息:Microsoft.Hosting.Lifetime[0]
      托管环境:开发
信息:Microsoft.Hosting.Lifetime[0]
      内容根路径:C:\Users\xxx\Downloads\AspNetCore.Docs-master\AspNetCore.Docs-master\aspnetcore\fundamentals\servers\httpsys\samples\3.x\SampleApp

我使用 Windows 身份验证创建了一个新的 Blazor 应用程序。(Visual Studio 2019 V16.4.0,.Net Core 3.1)。

现在,在 Visual Studio 中使用 IIS Express 运行时,Windows 身份验证有效(网页右上角显示“Hello Domain\Username!”)。但是当作为 Kestrel 应用程序运行时,Windows 身份验证不起作用。

我按照以下链接中的步骤使 Windows 身份验证与 Http.Sys 一起工作。(顺便说一句,我试过 [Kestrel/Negotiate][1] 但没有运气)

https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/httpsys?view=aspnetcore-3.1

基本上,它只是添加了webBuilder.UseHttpSys()in CreateHostBuilder()in的调用Program.cs

    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseHttpSys(options =>
                {
                    options.AllowSynchronousIO = true;
                    options.Authentication.Schemes = AuthenticationSchemes.None;
                    options.Authentication.AllowAnonymous = true;
                    options.MaxConnections = null;
                    options.MaxRequestBodySize = 30000000;
                    // options.UrlPrefixes.Add("http://*:5005");
                });
                webBuilder.UseStartup<Startup>();
            });

但是,运行应用程序会得到一个错误页面,其中包含以下消息

This site can’t be reached
The connection was reset.

或者

This site can’t provide a secure connection
localhost sent an invalid response.

Edge 的错误消息是:

There was a temporary DNS error. Try refreshing the page.
Error Code: INET_E_RESOURCE_NOT_FOUND

IE 错误信息:

无法安全连接到此页面

这可能是因为该站点使用过时或不安全的 TLS 安全设置。如果这种情况持续发生,请尝试联系网站所有者。

4

1 回答 1

0

解决方案是重新定位您的证书,并进行一些似乎不必要的手动配置:我非常密切地关注 http.sys 示例的配置 Windows Server部分,但遇到了netsh http sslcert命令问题. 问题在于dotnet dev-certs https --trust安装证书的位置!在使用“dotnet dev-certs https”创建的证书的默认位置是什么中指出,该工具将证书安装在当前用户的证书存储中,而不是本地计算机存储中。我必须将两个证书存储都添加到并将证书mmc复制localhostCertificates (Local Computer)\Personal\Certificates中,此时 sslcert 命令完成,当我运行测试应用程序时,它能够成功连接到 TLS。

于 2021-04-05T19:05:43.343 回答