Skip to content

Commit 28aac7f

Browse files
silverwindjasnell
authored andcommitted
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: #3132 PR-URL: #3147 Reviewed-By: Fedor Indutny <[email protected]>
1 parent b3c5ad1 commit 28aac7f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

doc/api/tls.markdown

+10
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,16 @@ perform lookup in external storage using given `sessionId`, and invoke
603603
NOTE: adding this event listener will have an effect only on connections
604604
established after addition of event listener.
605605

606+
Here's an example for using TLS session resumption:
607+
608+
var tlsSessionStore = {};
609+
server.on('newSession', function(id, data, cb) {
610+
tlsSessionStore[id.toString('hex')] = data;
611+
cb();
612+
});
613+
server.on('resumeSession', function(id, cb) {
614+
cb(null, tlsSessionStore[id.toString('hex')] || null);
615+
});
606616

607617
### Event: 'OCSPRequest'
608618

0 commit comments

Comments
 (0)