resumeSession event (tls.Server)

Event: 'resumeSession'

function (sessionId, callback) { }

Emitted when the client wants to resume the previous TLS session. The event listener may perform a lookup in external storage using the given sessionId and invoke callback(null, sessionData) once finished. If the session can't be resumed (i.e., doesn't exist in storage) one may call callback(null, null). Calling callback(err) will terminate incoming connection and destroy the socket.

NOTE: adding this event listener will only have an effect on connections established after the addition of the event listener.

Here's an example for using TLS session resumption:

var tlsSessionStore = {};
server.on('newSession', (id, data, cb) => {
  tlsSessionStore[id.toString('hex')] = data;
  cb();
});
server.on('resumeSession', (id, cb) => {
  cb(null, tlsSessionStore[id.toString('hex')] || null);
});
doc_Nodejs
2016-04-30 04:42:15
Comments
Leave a Comment

Please login to continue.