Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js sample configurations? #20

Closed
dahjelle opened this issue Jan 24, 2015 · 10 comments
Closed

Node.js sample configurations? #20

dahjelle opened this issue Jan 24, 2015 · 10 comments

Comments

@dahjelle
Copy link

I realize configuring a Node.js server is a bit of a different beast than the other servers…but it'd be nice to have some examples of how to configure the built-in HTTPS server in Node.js to your recommendations.

Thanks for the great resource!

@gene1wood
Copy link
Collaborator

Great idea. Can you provide some example configs to work from?

@dahjelle
Copy link
Author

Well, I'm not any sort of HTTPS or HTTPS-in-Node expert, but I can definitely throw in some example configs (from my own code and the docs) that perhaps can serve as the basis for experts to modify?

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

var options = {
    key: fs.readFileSync('key.pem'),
    cert: fs.readFileSync('cert.pem'),
    ciphers: [
        'ECDHE-RSA-AES256-SHA384',
        'DHE-RSA-AES256-SHA384',
        'ECDHE-RSA-AES256-SHA256',
        'DHE-RSA-AES256-SHA256',
        'ECDHE-RSA-AES128-SHA256',
        'DHE-RSA-AES128-SHA256',
        'HIGH',
        '!aNULL',
        '!eNULL',
        '!EXPORT',
        '!DES',
        '!RC4',
        '!MD5',
        '!PSK',
        '!SRP',
        '!CAMELLIA'
    ].join(':'),
    ecdhCurve: 'prime256v1', // this is the default
    honorCipherOrder: true,
    secureOptions: require('constants').SSL_OP_NO_SSLv3|require('constants').SSL_OP_NO_TLSv1|require('constants').SSL_OP_NO_SSLv2
};

https.createServer(options, function (req, res) {
  res.writeHead(200);
  res.end("hello world\n");
}).listen(8000, '127.0.0.1');

Most of that configuration is from the Node.js TLS documentation, with bits from the HTTPS documentation and the list of ciphers from io.js's default list (more discussion on that list is on the pull request).

Again, I'm not qualified to certify or recommend this configuration, but hopefully it can serve as a starting point!

@mikemaccana
Copy link

It might be better to simply port the whole thing to node. ie, rather than generate a config, and loading that with node, have a module that sets options accordingly - that way, when the module is updated, the cyphers are updated.

@dahjelle
Copy link
Author

I definitely like the idea of an NPM module, or perhaps a collection of them for each of the compatibility options. Perhaps something that would simplify the code above to something like:

var https = require('https');
var fs = require('fs');
var mozTLS = require('moz-tls');

var options = mozTLS.modern({
    key: fs.readFileSync('key.pem'),
    cert: fs.readFileSync('cert.pem')
});

https.createServer(options, function (req, res) {
  res.writeHead(200);
  res.end("hello world\n");
}).listen(8000, '127.0.0.1');

or some such. Perhaps it could even validate the keys themselves to conform to recommendations?

@mikemaccana
Copy link

@dahjelle exactly. I'm going to have a go at this tomorrow, will let you know once 0.0.1 is published.

@dahjelle
Copy link
Author

@mikemaccana Sweet! Thanks! I'm looking forward to it!

@mikemaccana
Copy link

Just published: https://www.npmjs.com/package/ssl-config

which in turn relies on another new package https://www.npmjs.com/package/minimum-tls-version

@dahjelle
Copy link
Author

dahjelle commented Apr 1, 2015

@mikemaccana Awesome! Thanks for doing this—I've put it on my list to implement in our app. Much appreciated!

@gene1wood
Copy link
Collaborator

So it looks likes this is completed now that @mikemaccana published his npm.

If there's any way you can think of for future Mozilla ciphersuite changes to be rendered into your nodejs module, let me know. Nothing clever is coming to mind.

@mikemaccana
Copy link

@gene1wood I'm now watching the server-side-tls project, so should see all updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants