【问题标题】:Kestrel: An anonymous request was received in between authentication handshake requests?Kestrel:在身份验证握手请求之间收到匿名请求?
【发布时间】:2019-12-04 22:43:05
【问题描述】:

我创建了一个 Kestrel Asp.Net 核心应用程序并尝试将它托管在 Windows Server (server1) 上。我使用

启动应用程序

在 server1 上浏览 http://server1:8008 没有任何错误。

但是,在远程机器上浏览http://server1:8008时,出现如下错误?

PS C:\Websites\Portal> .\Blazor.exe --urls http://server1:8008
info: Microsoft.Hosting.Lifetime[0]
      Now listening on: http://[::]:8008
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: C:\Websites\Portal
warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]
      Failed to determine the https port for redirect.
fail: Microsoft.AspNetCore.Authentication.Negotiate.NegotiateHandler[5]
      An exception occurred while processing the authentication request.
System.InvalidOperationException: An anonymous request was received in between authentication handshake requests.
   at Microsoft.AspNetCore.Authentication.Negotiate.NegotiateHandler.HandleRequestAsync()
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
      An unhandled exception has occurred while executing the request.
System.InvalidOperationException: An anonymous request was received in between authentication handshake requests.
   at Microsoft.AspNetCore.Authentication.Negotiate.NegotiateHandler.HandleRequestAsync()
   at Microsoft.AspNetCore.Authentication.Negotiate.NegotiateHandler.HandleRequestAsync()
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware midd
leware, HttpContext context, Task task)

【问题讨论】:

  • 1.根据这个test,如果您发送另一个没有授权标头的请求之前的请求已经开始身份验证但之前在一个连接期间身份验证已经完成,它必须抛出。
  • 2. (太长,无法粘贴到单个评论中):另见source code。所以这是一种设计行为。
  • 为什么只在远程机器上浏览不起作用?

标签: asp.net asp.net-core kestrel-http-server


【解决方案1】:

有点旧,但是,对此进行更正....

您需要为您的应用程序设置 SPN。一旦正确的 SPN 到位,问题应该会消失。

【讨论】:

    猜你喜欢
    • 2020-03-30
    • 2012-09-10
    • 2014-01-15
    • 1970-01-01
    • 1970-01-01
    • 2012-05-01
    • 1970-01-01
    • 2011-03-01
    相关资源
    最近更新 更多