You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
HTTP2: SocketsHttpHandler doesn't downgrade to HTTP/1.1 during Windows authentication #1582
When SocketsHttpHandler connects to a server using HTTP/2, it is unable to downgrade to HTTP/1.1 when the server requests Windows authentication (Negotiate or NTLM). The net result is that 401 is returned to the client without even trying to reconnect (with HTTP/1.1) and send credentials.
// Repro will be posted later
Reacted by angelofb, Brennan, Giorgi Chakhidze and Morten Nielsen
I noticed this while doing some auth testing. IE, Chrome, and Edge all have this fallback behavior. Also, the downgrade isn't just for the auth handshake, all subsequent requests are made on the HTTP/1.1 connection so they share the cached auth context.
WinHttpHandler is a bit different. The first HTTP/2 request challenges, falls back to HTTP/1.1, authenticates, and completes successfully. However, the next request is still made over HTTP/2, the client attempts the fallback again, and then it re-authenticates on the already authenticated connection. That could be a major performance hole to fall into.
This came up again. This time from a SignalR client user. See dotnet/aspnetcore#45371. Prior to .NET 7, the SignalR client forced HTTP/1.1 but we started allowing HTTP/2 in .NET 7. We're considering backporting a fix for SignalR to force HTTP/1.1 if the customer sets HttpConnectionOptions.UseDefaultCredentials to true.
@karelz Even though we have a fix for SignalR, we can't help but think HttpClient should have avoided this for us. Do you think we could do something similar in .NET 8 at the SocketsHttpHandler level when UseDefaultCredentials is set? Of course, the handler could be smarter than SignalR and wait for a challenge before downgrading,
get parity with WinHttp - The existing retry logic will be problematic as this needs new connection (and possibly check for version policy). This can probably be done by refactoring the connection pool logic.
Browsers do have global cache and therefore they can remember state. HttpClientHandler is stateless and each request is processed independently. To fix that, we would need whole new concept in SocketsHttpHandler. That may be useful for other reasons but it would be fundamental change IMHO.
While we should do something I would keep it in Future for now given complexity and no up votes e.g. no real customer pain. The workaround is somewhat easy -> just set version to 1.1 for problematic sites.
Agreed with @wfurt. It seems it is still rather rare with a complex solution, so leaving it in Future sounds like the right option now. @halter73 let us know if you disagree.
This is a major blocker for us. When a user connects to a service, we don't necessarily know up-front whether it'll be IWA secured. On Windows and Mac we rely on default authentication, so it is completely transparent to the user who just gets auto-signed in. But with http/2 turned on we get a 401 indicating the user's default credential aren't valid and they should provide another set of credentials, but those credentials will also fail. We have no insight into whether the 401 is because of IWA or something else, so our only option is to basically downgrade all webrequests to http/1.1 just in case it hits an IWA service.
We need some way to detect the request is failing due to IWA so we can downgrade dynamically.
With PKI authentication we get a specific ProtocolError exception, so we can downgrade ourselves, but with IWA we can't tell the reason for the failure is because of the protocol. The exception thrown is identical to just not providing a credential on http1.1.
Our QT team hit the same issue with IWA, but they get a callback before connection completes that indicates that IWA credentials are being requested, so if the request fails, they know they just need to downgrade. There doesn't seem to be anything equivalent in .NET.
The change I just merged #123827 works by remembering whether we see a session auth response on HTTP/2, and downgrading all future requests to that endpoint to use HTTP/1.1 (when allowed by version & policy). The initial H2 request that hits this will also be retried as long as it doesn't have a content.
@dotMorten Would you be able to test how this works in practice in your scenario once the preview with the change comes out (probably p4)?
Activity
geoffkizer commentedon Feb 10, 2019
See also dotnet/corefx#31304
karelz commentedon Apr 25, 2019
@wfurt can you please chat with @davidsh about design / ideas here?
karelz commentedon Apr 25, 2019
Given we scoped HTTP/2 to gRPC scenarios, this can wait for post-3.0.
davidsh commentedon Apr 25, 2019
Waiting for post-3.0 is ok as long as we don't opt-in by default for HTTP/2.0.
Tratcher commentedon May 6, 2019
I noticed this while doing some auth testing. IE, Chrome, and Edge all have this fallback behavior. Also, the downgrade isn't just for the auth handshake, all subsequent requests are made on the HTTP/1.1 connection so they share the cached auth context.
WinHttpHandler is a bit different. The first HTTP/2 request challenges, falls back to HTTP/1.1, authenticates, and completes successfully. However, the next request is still made over HTTP/2, the client attempts the fallback again, and then it re-authenticates on the already authenticated connection. That could be a major performance hole to fall into.
halter73 commentedon Dec 5, 2022
This came up again. This time from a SignalR client user. See dotnet/aspnetcore#45371. Prior to .NET 7, the SignalR client forced HTTP/1.1 but we started allowing HTTP/2 in .NET 7. We're considering backporting a fix for SignalR to force HTTP/1.1 if the customer sets
HttpConnectionOptions.UseDefaultCredentialsto true.@karelz Even though we have a fix for SignalR, we can't help but think HttpClient should have avoided this for us. Do you think we could do something similar in .NET 8 at the SocketsHttpHandler level when UseDefaultCredentials is set? Of course, the handler could be smarter than SignalR and wait for a challenge before downgrading,
karelz commentedon Jan 5, 2023
@wfurt @ManickaP @CarnaViire any thoughts on this? (marking for re-triage given new scenario being impacted)
wfurt commentedon Jan 5, 2023
There are (at least) two distance parts IMHO.
HttpClientHandleris stateless and each request is processed independently. To fix that, we would need whole new concept inSocketsHttpHandler. That may be useful for other reasons but it would be fundamental change IMHO.While we should do something I would keep it in
Futurefor now given complexity and no up votes e.g. no real customer pain. The workaround is somewhat easy -> just set version to 1.1 for problematic sites.karelz commentedon Jan 24, 2023
Agreed with @wfurt. It seems it is still rather rare with a complex solution, so leaving it in Future sounds like the right option now.
@halter73 let us know if you disagree.
dotMorten commentedon Jan 30, 2026
This is a major blocker for us. When a user connects to a service, we don't necessarily know up-front whether it'll be IWA secured. On Windows and Mac we rely on default authentication, so it is completely transparent to the user who just gets auto-signed in. But with http/2 turned on we get a 401 indicating the user's default credential aren't valid and they should provide another set of credentials, but those credentials will also fail. We have no insight into whether the 401 is because of IWA or something else, so our only option is to basically downgrade all webrequests to http/1.1 just in case it hits an IWA service.
We need some way to detect the request is failing due to IWA so we can downgrade dynamically.
With PKI authentication we get a specific ProtocolError exception, so we can downgrade ourselves, but with IWA we can't tell the reason for the failure is because of the protocol. The exception thrown is identical to just not providing a credential on http1.1.
Our QT team hit the same issue with IWA, but they get a callback before connection completes that indicates that IWA credentials are being requested, so if the request fails, they know they just need to downgrade. There doesn't seem to be anything equivalent in .NET.
MihaZupan commentedon Apr 18, 2026
The change I just merged #123827 works by remembering whether we see a session auth response on HTTP/2, and downgrading all future requests to that endpoint to use HTTP/1.1 (when allowed by version & policy). The initial H2 request that hits this will also be retried as long as it doesn't have a content.
@dotMorten Would you be able to test how this works in practice in your scenario once the preview with the change comes out (probably p4)?
dotMorten commentedon Apr 21, 2026
@MihaZupan Yes I'll take a look then. Thanks!