使Http.sys与Windows身份验证一起使用

时间:2019-11-28 08:37:43

标签: c# asp.net-core windows-authentication blazor httpsys

我尝试通过以下链接使Kestrel能够进行Window身份验证:

https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/httpsys?view=aspnetcore-3.0#how-to-use-httpsys https://docs.microsoft.com/en-us/aspnet/core/security/authentication/windowsauth?view=aspnetcore-3.0&tabs=visual-studio#httpsys

这是代码。

    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("https://localhost:8080");
                });
                webBuilder.UseStartup<Startup>()
                    .UseHttpSys(options =>
                    {
                        options.Authentication.Schemes =
                            AuthenticationSchemes.NTLM |
                            AuthenticationSchemes.Negotiate;
                        options.Authentication.AllowAnonymous = false;
                    });
            });

但是,浏览https://localhost:8080显示以下错误消息(边缘)吗?

  

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

1 个答案:

答案 0 :(得分:2)

这是因为您的计算机上未安装开发认证。 试试这个:

dotnet dev-certs https --trust