doc: add TLS session resumption example

Using TLS session resumption correctly is not obvious. This added
example code should help new users understand how to use it correctly.

Related issue: https://github.com/nodejs/node/issues/3132
PR-URL: https://github.com/nodejs/node/pull/3147
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
This commit is contained in:
Roman Reiss 2015-10-06 20:50:45 +02:00
parent 17665af02f
commit 07a84191c0

View File

@ -603,6 +603,16 @@ perform lookup in external storage using given `sessionId`, and invoke
NOTE: adding this event listener will have an effect only on connections NOTE: adding this event listener will have an effect only on connections
established after addition of event listener. established after addition of event listener.
Here's an example for using TLS session resumption:
var tlsSessionStore = {};
server.on('newSession', function(id, data, cb) {
tlsSessionStore[id.toString('hex')] = data;
cb();
});
server.on('resumeSession', function(id, cb) {
cb(null, tlsSessionStore[id.toString('hex')] || null);
});
### Event: 'OCSPRequest' ### Event: 'OCSPRequest'