Skip to content

WebSockets - custom validation of server certificate #102

Closed
@tintoy

Description

@tintoy

Hey, @brendanburns, as previously discussed in tintoy/dotnet-kube-client#6 I'm happy to contribute my WebSocket functionality (which includes support for custom verification of the server certificate).

But I figured it'd be worth discussing here first :)

The big gotcha (currently) is that it has a dependency on netcoreapp2.1 because in previous versions of corefx WebSockets used WinHTTP on Windows (which didn't honour a subset of the certificate options on ClientWebSocketOptions) and something else on OSX / Linux (which didn't honour a different subset of the certificate options). In 2.1, the WebSockets implementation is entirely implemented in managed code and fully supports customisation of SSL certificate usage / validation.

As it stands, here's how I implemented it:

https://github.com/tintoy/dotnet-kube-client/blob/develop/src/KubeClient.Extensions.WebSockets/K8sWebSocketOptions.cs#L13
https://github.com/tintoy/dotnet-kube-client/blob/develop/src/KubeClient.Extensions.WebSockets/K8sWebSocket.cs#L31

I borrowed some of the original ClientWebSocket code from .NET Core 2.0 and modified it to work with 2.1-preview1 (but from 2.1-preview2 onwards, the ManagedWebSocket types will be publicly available and much of this code can be eliminated).

The latest code from corefx is a fair bit simpler because the required managed types are available internally:

https://github.com/dotnet/corefx/blob/f1f3b3f8af21c0f782f7f0699d505a0cdb9026ba/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/WebSocketHandle.Managed.cs#L71

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions