Node.js + SSL support

2019-03-29 10:27发布

问题:

Recent commits reference TLS progress. Any idea when it will be ready?

If not, what are the options for using SSL with a node app at the present time? Reverse proxy nginx? Is there a good tutorial available for using SSL with node?

Most professional apps need to support SSL these days and it would be great to be able to use node for these now.

回答1:

From my experience node 0.2 SSL support is very flacky and unreliable. We use nginx as a proxy.



回答2:

Node.js 0.3.4 has been released.

  • Primordal mingw build (Bert Belder)
  • HTTPS server
  • Built in debugger 'node debug script.js'
  • realpath files during module load (Mihai Călin Bazon)
  • Rename net.Stream to net.Socket
  • Fix process.platform

Example

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

var options = {
  key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
  cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
};

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


回答3:

Node 3.x is not supposed to be used in production, it's unstable, bleeding edge development. 2.6 still has the old SSL implementation, which works.

If you want to know when all the stuff gets finished, your best bet is to either ask on the Google Group, or Ryan on Twitter.



回答4:

Just for reference ... here's a JavaScript implementation of SSL/TLS:

https://github.com/digitalbazaar/forge

At the moment, it is only a client-side implementation. It would need to be expanded to cover server-side. For someone with a little knowledge about how TLS works, however, it shouldn't be too difficult to add to the existing framework.



标签: ssl node.js