Developing Secure WebSocket Server using C#

Viewed 4079

I am new to C# programming and have managed to develop non-secure C# websocket server. The server is working as expected with clients connecting to server from browser and c# client application using ws://serverhostname:portnumber.

Now, we have to move the working server to secure websocket server. I tried looking into many sites for help but still not very clear with the way to support secure websocket communication.

After lot of research on internet, i found that we below on server to create the secure websocket server.

  1. Create Signed Certificate on the server to use in AuthenticateAsServer.
  2. Use SslStream class to create the secure stream.

But things which are still not clear to me are.

  1. Do we need to use only SslStream object for sending and receiving data on secure websocket or we need use SslStream only for handshake and then use socket object (like my non secure server) to send and receive the data on the websocket.
  2. Do we need to perform websocket handshake between client and server i.e. to upgrade from http to websocket
  3. How do we encrypt or decrypt the data on SslStream.

Could you please help me with source code or links for the source code reference as i have tried all possible to get the information but could not find any as of now.

0 Answers
Related