Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Improvements to TLS support. #69

Closed
wants to merge 4 commits into from

2 participants

@ahhentz

Allow the client to specify a list of CAs in connect().
Make 'end' event work for TLS streams.

Augusto Henr... added some commits
Augusto Henrique Hentz Allow the client to specify a CA-list in connect(). 6d93b91
Augusto Henrique Hentz Make 'end' event work for TLS streams.
TLS streams do not emit the 'end' event, so notifications of connection
finish and reconnection do not work. This commit fixes this.
3836f37
Augusto Henrique Hentz Updates to the documentation
Description of valid fields in the options object.
072b650
Augusto Henrique Hentz Make dnode server emit 'end' on TLS connection close
TLS connections do not emit 'end'. Therefore, we must emit 'end' on the
TLS connection 'close' event.
ed46d2c
@substack substack closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 22, 2011
  1. Allow the client to specify a CA-list in connect().

    Augusto Henrique Hentz authored
Commits on Sep 23, 2011
  1. Make 'end' event work for TLS streams.

    Augusto Henrique Hentz authored
    TLS streams do not emit the 'end' event, so notifications of connection
    finish and reconnection do not work. This commit fixes this.
  2. Updates to the documentation

    Augusto Henrique Hentz authored
    Description of valid fields in the options object.
  3. Make dnode server emit 'end' on TLS connection close

    Augusto Henrique Hentz authored
    TLS connections do not emit 'end'. Therefore, we must emit 'end' on the
    TLS connection 'close' event.
This page is out of date. Refresh to see the latest.
Showing with 28 additions and 1 deletion.
  1. +25 −0 README.markdown
  2. +3 −1 index.js
View
25 README.markdown
@@ -209,6 +209,31 @@ wire.
Returns `this` so you can chain middlewares.
+the options object
+==================
+
+You can pass an options object to the methods `connect()` and `listen()`. Valid
+fields for this object are:
+
+* `host` is the host to connect (client) or listen (server)
+
+* `port` is the port to connect (client) or listen (server)
+
+* `path` is the path to a Unix domain socket to connect (client) or listen (server)
+
+* `reconnect` (for clients): time to wait between reconnections
+
+* `key` private key for TLS streams (required for encrypted communication)
+
+* `cert` certificate for TLS streams (required for servers)
+
+* `ca` list of trusted certificates
+
+* `requestCert` (for servers) `true` to request client certificates
+
+* `rejectUnauthorized` (for servers) `true` to terminate connections with
+no or invalid certificates
+
the connection object
=====================
View
4 index.js
@@ -33,10 +33,11 @@ dnode.prototype.connect = function () {
if (params.port) {
params.host = params.host || '127.0.0.1';
if (params.key) {
- var options = { key: params.key, cert: params.cert };
+ var options = { key: params.key, cert: params.cert, ca : params.ca };
stream = tls.connect(params.port, params.host, options, function() {
attachDnode();
});
+ stream.once('close', function() { stream.emit('end'); });
}
else {
stream = net.createConnection(params.port, params.host);
@@ -226,6 +227,7 @@ function createClient (proto, stream) {
client.end = stream.end.bind(stream);
client.destroy = stream.destroy.bind(stream);
+ stream.on('close', client.emit.bind(client, 'end'));
stream.on('end', client.emit.bind(client, 'end'));
client.on('request', function (req) {
Something went wrong with that request. Please try again.