在 node/sails js 中启用 Session 恢复

Enabling Session resumption in node/sails js

我一直致力于提高基于 node/sails.js 的网站的 ssllabs 评级,但我无法启用 session 恢复。到目前为止,我得到的信息是 IDs assigned but not accepted.

我在 express node.js 应用 here 中找到了一些关于如何做到这一点的信息,但我不确定这段代码应该 运行 在 sails.js 框架中的什么位置或者帆在哪里 var server = tls.createServer();.

应该在中间件里面吧?

谢谢

好的,我找到了方法。 在我刚刚做的 http.js 文件中:

customMiddleware: function(app) {
console.log("config of Middleware is called");
//session resumption/reuse enabled
var server = sails.hooks.http.server;
var tlsSessionStore = {};

server.on("newSession", function (id, data, cb) {
  tlsSessionStore[id.toString("hex")] = data;
  cb();
});

server.on("resumeSession", function (id, cb) {
  var tlsSessionId = id.toString("hex");
  cb(null, (tlsSessionId in tlsSessionStore) ? tlsSessionStore[tlsSessionId] : null);
});
},

并且我在 order[ ] 中添加了自定义中间件。