mcollina/mows — pull request #2 by ldstein (2013-11-12 02:05:29+00:00)
Title: Support for MOWS over HTTPS

This patch adds support for secure connections.

It includes a new method, createSecureServer:

```javascript

var clientHandler = function(client) {
// Handle client
}

var secureOpts = {
key: fs.readFileSync('./secure-test/cert/24485013-my.webserver.com.key'),
cert: fs.readFileSync('./secure-test/cert/24485013-my.webserver.com.cert')
}

mows.createSecureServer(secureOpts, clientHandler).listen(666);
```

To create a secure browser client, specify the 'wss' protocol:

```javascript
// ws is unsecure, wss is secure:
var unsecureClient = mows.createClient(665, 'ws://my.webserver.com');
var secureClient = mows.createClient(666, 'wss://my.webserver.com');
```

To create a secure Node client, define a protocol object and pass appropriate certificates, authentication options, etc:

```javascript

// See http://nodejs.org/api/https.html#https_https_request_options_callback
var secureClientOpts =
{
protocol:
{
ca: fs.readFileSync('./secure-test/cert/24485013-my.webserver.com.cert')
}
};

var secureClient = mows.createClient(666, 'wss://my.webserver.com', secureClientOpts);
applyEventHandlers(unsecureClient2);
```