Skip to content

Update javascript/transport/node_http.js #165

Closed
wants to merge 2 commits into from

3 participants

@madscientistmanny

Merges the options passed to faye.client to ensure the  certificate info gets 
passed to tls.connect.

In order for this to work requires one of two creations of the options object with the client.
Note: options.agent creation is mandatory for some reason
        1)
        var options = {
          passphrase: 'password'
          ,pfx: fs.readFileSync("ssl/agent1.pfx")
          ,timeout: 120
        };
        options.agent = new https.Agent(options);
        var client = new faye.Client('https://localhost:4443/faye', options);

        2)
        var options = {
           passphrase: 'password'
           ,key: fs.readFileSync("ssl/agent1-key.pem")
           ,cert: fs.readFileSync("ssl/agent1-cert.pem")
           ,timeout: 120
        };
        options.agent = new https.Agent(options);
        var client = new faye.Client('https://localhost:4443/faye', options);

Server would look something like this:

var https = require('https')
    , faye = require('faye')
    , fs = require('fs');

//faye.Logging.logLevel = 'debug';
var bayeux = new faye.NodeAdapter({mount: '/faye', timeout: 45});

var options = {
    passphrase: 'password',
    key: fs.readFileSync('ssl/server-key.pem'),
    cert: fs.readFileSync('ssl/server-cert.pem'),
    ca:     [fs.readFileSync('ssl/ca1-cert.pem')],
    requestCert:        true,
    rejectUnauthorized: true
};
options.agent = new https.Agent(options);

var server = https.createServer(options, ServerAuthHandler);
console.log('server created');
bayeux.attach(server);
console.log('bayeux listener attached');
server.listen(4443);
console.log('server listening on 4443');

@madscientistmanny madscientistmanny Update javascript/transport/node_http.js
Merges the options passed to faye.client to ensure the  certificate info gets 
passed to tls.connect.

In order for this to work requires one of two creations of the options object.
Note: options.agent creation is mandatory for some reason
        1)
        var options = {
          passphrase: 'password'
          ,pfx: fs.readFileSync("ssl/agent1.pfx")
          ,timeout: 120
        };
        options.agent = new https.Agent(options);
        var client = new faye.Client('https://localhost:4443/faye', options);

        2)
        var options = {
           passphrase: 'password'
           ,key: fs.readFileSync("ssl/agent1-key.pem")
           ,cert: fs.readFileSync("ssl/agent1-cert.pem")
           ,timeout: 120
        };
        options.agent = new https.Agent(options);
        var client = new faye.Client('https://localhost:4443/faye', options);

Server would look something like this:

var https = require('https')
    , faye = require('faye')
    , fs = require('fs');




//faye.Logging.logLevel = 'debug';
var bayeux = new faye.NodeAdapter({mount: '/faye', timeout: 45});




var options = {
    passphrase: 'password',
    key: fs.readFileSync('ssl/server-key.pem'),
    cert: fs.readFileSync('ssl/server-cert.pem'),
    ca:     [fs.readFileSync('ssl/ca1-cert.pem')],
    requestCert:        true,
    rejectUnauthorized: true
};
options.agent = new https.Agent(options);




var server = https.createServer(options, ServerAuthHandler);
console.log('server created');
bayeux.attach(server);
console.log('bayeux listener attached');
server.listen(4443);
console.log('server listening on 4443');
bc8593b
@madscientistmanny madscientistmanny Update javascript/transport/node_http.js
Forgot a semicolon;
6e89eaf
@mhuggins mhuggins commented on the diff Sep 28, 2012
javascript/transport/node_http.js
@@ -8,8 +8,10 @@ Faye.Transport.NodeHttp = Faye.extend(Faye.Class(Faye.Transport, {
self = this;
var cookies = this.cookies.getCookies({domain: uri.hostname, path: uri.pathname}),
- params = this._buildParams(uri, content, cookies, secure),
- request = client.request(params);
+ params = this._buildParams(uri, content, cookies, secure);
+ //small hack to pass certs from faye.client call down tls.connect further down the chain
+ Faye.extend(params,this._client._options);
+ var request = client.request(params);
@mhuggins
mhuggins added a note Sep 28, 2012

Tabbing on the above three lines is off. They should be four spaces to the left.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jcoglan
Collaborator
jcoglan commented Oct 13, 2012

Closing for now after conversation w/ @madscientistmanny indicated this feature is not useful in its current state.

@jcoglan jcoglan closed this Oct 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.