Language: HTML | XAML

How to secure WebSocket connections with TLS/SSL (XAML)

Applies to Windows and Windows Phone

This topic explains how to secure WebSocket connections with Transport Layer Security (TLS)/Secure Sockets Layer (SSL) when using the StreamWebSocket and MessageWebSocket features in Windows 8 for a Windows Store app.

In most cases you'll want to use a secure WebSocket connection. This will increase the chances that your connection will succeed, as many proxies will reject unencrypted WebSocket connections.

Technologies

Instructions

Step 1: Use the wss: URI scheme

The WebSocket Protocol defines two URI schemes. ws: is used for unencrypted connections, while wss: is used for secure connections that should be encrypted.

  • To encrypt your connection, use the wss: URI scheme. For example:
    
    
    webSocket = new MessageWebSocket();
    await webSocket.ConnectAsync("wss://www.example.com");
    
    
    

Remarks

For additional details on the WebSocket URI schemes, see the WebSocket Protocol.

Related topics

Other
Connecting with WebSockets
Create your first Windows Runtime app using C# or Visual Basic
Create your first Windows Runtime app using C++
How to configure network capabilities
How to connect with a MessageWebSocket
How to connect with a StreamWebSocket
How to use advanced WebSocket controls
Reference
MessageWebSocket
MessageWebSocket.ConnectAsync
StreamWebSocket
StreamWebSocket.ConnectAsync
Windows.Networking.Sockets
Samples
WebSocket sample

 

 

Show:
© 2014 Microsoft