title: How do I set the ClientWebSocketOptions on a ClientWebSocket in the System.Net.WebSockets
body: <p>I want to specify an <em>ssl certificate</em> for a web <em>socket client</em> to use when connecting to a <em>web socket server</em>.</p>
  <p>The only <a href="https://docs.microsoft.com/en-us/dotnet/api/system.net.websockets.clientwebsocket.-ctor?view=netcore-3.1" rel="nofollow noreferrer">constructor</a> for a <code>System.Net.WebSockets.ClientWebSocket</code> has 0 parameters. I would expect there to be an override with (Options) as a parameter but there is not.</p>
  <p>The <a href="https://docs.microsoft.com/en-us/dotnet/api/system.net.websockets.clientwebsocket.connectasync?view=netcore-3.1" rel="nofollow noreferrer">ConnectAsync</a> method has 2 parameters: <code>Uri</code> and <code>CancellationToken</code>.  I would expect there to be an override with <code>(Uri, CancellationToken, Options)</code> but there is not.</p>
  <p>The <code>ClientWebSocket</code> <a href="https://docs.microsoft.com/en-us/dotnet/api/system.net.websockets.clientwebsocket.options?view=netcore-3.1" rel="nofollow noreferrer">Options</a> property is get but not set, so i cannot call</p>
  <pre><code>ws.options = MyClientWebSocketOptions
  </code></pre>
  <p>There is no <code>SetOptions</code> method on the <code>ClientWebSocket</code> class.</p>
  <p>The <a href="https://docs.microsoft.com/en-us/dotnet/api/system.net.websockets.clientwebsocketoptions?view=netcore-3.1" rel="nofollow noreferrer">ClientWebSocketOptions</a> class has a <a href="https://docs.microsoft.com/en-us/dotnet/api/system.net.websockets.clientwebsocketoptions.clientcertificates?view=netcore-3.1#System_Net_WebSockets_ClientWebSocketOptions_ClientCertificates" rel="nofollow noreferrer">ClientCertificates</a> property that is is set-able, so I have assumed this is the way to specify the <em>certificate</em>.</p>
  <p>I can create a <code>ClientWebSocketOptions</code> with the correct <em>certificate</em>, but i need to know how to make a <code>ClientWebSocket</code> use those options.</p>