The 'resumeSession' event is emitted when the client requests to resume a previous TLS session. The listener callback is passed two arguments when called:

    • sessionId {Buffer} The TLS session identifier
    • callback {Function} A callback function to be called when the prior session has been recovered: callback([err[, sessionData]])
      • err {Error}
      • sessionData {Buffer}

    The event listener should perform a lookup in external storage for the sessionData saved by the ['newSession'][] event handler using the given sessionId. If found, call callback(null, sessionData) to resume the session. If not found, the session cannot be resumed. callback() must be called without sessionData so that the handshake can continue and a new session can be created. It is possible to call callback(err) to terminate the incoming connection and destroy the socket.

    Listening for this event will have an effect only on connections established after the addition of the event listener.

    The following illustrates resuming a TLS session:

    1. const tlsSessionStore = {};
    2. server.on('newSession', (id, data, cb) => {
    3. tlsSessionStore[id.toString('hex')] = data;
    4. cb();
    5. });
    6. server.on('resumeSession', (id, cb) => {
    7. cb(null, tlsSessionStore[id.toString('hex')] || null);
    8. });