Change WebSocket handshake implementation to align with the .NET approach#5740
Open
imcarolwang wants to merge 4 commits into
Open
Change WebSocket handshake implementation to align with the .NET approach#5740imcarolwang wants to merge 4 commits into
imcarolwang wants to merge 4 commits into
Conversation
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
imcarolwang
marked this pull request as ready for review
February 27, 2025 02:57
Restore behavior that was lost when ClientWebSocket.ConnectAsync was replaced with the manual SocketsHttpHandler-based handshake: - Initialize _webRequestTokenProvider / _webRequestProxyTokenProvider via CreateAndOpenTokenProvidersAsync at the top of SetupInvoker; otherwise GetCredentialAsync and the proxy factory receive null providers, breaking Basic/Digest/Negotiate/NTLM client auth and authenticated proxy. - Set the Host request header via MapIdentity / GetIdentityHostHeader so EndpointIdentity-based Kerberos SPN/DNS/UPN scenarios continue to authenticate against the identity host instead of the URI host. - Pass a cancellation token derived from TimeoutHelper into SendAsync so OpenAsync(timeout) honors the user-supplied timeout instead of hanging on DNS/TCP/TLS/server stalls. - Stop setting handler.UseProxy = false in the no-explicit-proxy branch; leaving the SocketsHttpHandler default preserves system / default web proxy behavior, matching the prior ClientWebSocket implementation. - Remove the while(true) + HttpRequestError.ExtendedConnectNotSupported catch: the request is hard-coded to HTTP/1.1 with RequestVersionExact per Matt's guidance, so the catch was dead code with an infinite-loop hazard if it ever fired. - After parsing Sec-WebSocket-Protocol, fail when the client requested a subprotocol but the server returned none, preserving the prior strict WCF behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds an outerloop scenario test that configures NetHttpsBinding with WebSocketTransportUsage.Always and a custom ServiceCertificate.SslCertificateAuthentication validator, but does NOT require a client certificate. This is the exact scenario from issue dotnet#5729: prior to the fix, the custom RemoteCertificateValidationCallback was only wired when RequireClientCertificate was true, so the validator was silently bypassed. The test asserts that the custom validator's Validate method was actually invoked during the WebSocket handshake, which would have failed before the fix. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For issue #5729 .