nodejs + socket.io 是否可以加密通信?
 发布于 12 年前  作者 leon0615  7251 次预览  最后一次回复是 12 年前  来自  

请教各位大神,nodejs 与 socket.io 长连接之间的信息交互如何通过SSL加密?

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);

这种应该不行吧 ? 界面上socket.io又如何去加载证书?