-
Notifications
You must be signed in to change notification settings - Fork 565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebSocket custom SSL validation only works when using client certificates #5729
Comments
@imcarolwang, in .NET Framework, we use HttpWebRequest to handle the initial connection including the WebSockets handshake, and then wrap the connection stream in a WebSocket to send/receive websocket messages. This enabled us to do everything with the initial connection that we can do with Http requests (certificates, headers etc). This wasn't available in earlier .NET Core days so we had to use the WebSocket class to make the connection and were limited to what settings can get set on it. Here's the entry point for the implementation on .NET Framework: An overview of the process on .NET is this:
The .NET code which does something similar starts here: Let me know if you need help understanding any of it. |
@mconnew, this is a very detailed write-up, and I believe I understand the main idea. However, after further checking the implementation by referring to the .NET source, I got stuck trying to understand where the options parameter for setting up the HttpMessageInvoker comes from if it's to be applied in the WCF implementation. The options is of type ClientWebSocketOptions, which seems to contain many configurable options that I believe are crucial for handling HTTP requests. Relevant .NET source: https://source.dot.net/#System.Net.WebSockets.Client/System/Net/WebSockets/WebSocketHandle.Managed.cs,248 I’ll read more carefully to better understand the process, but if you could shed some light on this, that would be great! |
ClientWebSocketOptions is what's passed to the WebSocket api to create a WebSocket when you aren't using the method of manually handling the initial handshake using SocketsHttpHandler. The various things passed in ClientWebSocketOptions, WCF gets from other places such as ClientCredentials (for client certificate for example), or HttpTransportBindingElement.WebSocketSettings (for sub protocol or keep alive interval for example). |
Describe the bug
It's possible to disable (or provide custom) SSL validation by setting
SslCertificateAuthentication
like in this example:However, this only works when using client certificate authentication.
Looking at:
wcf/src/System.ServiceModel.Http/src/System/ServiceModel/Channels/ClientWebSocketTransportDuplexSessionChannel.cs
Line 155 in f789e63
It seems like the WebSocket RemoteCertificateValidationCallback is only ever set if RequireClientCertificate is true, which will only be the case when using client certificates.
It should be possible to disable or customize server SSL certificate validation regardless of the auth type being used.
To Reproduce
Expected behavior
The call should succeed.
Actual behavior
Call fails with an error similar to this one:
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: