From 28aac7f19de0dc0b9c9fe19b2f59b6cc9aaba642 Mon Sep 17 00:00:00 2001 From: Roman Reiss Date: Tue, 6 Oct 2015 20:50:45 +0200 Subject: [PATCH] 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 --- doc/api/tls.markdown | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/api/tls.markdown b/doc/api/tls.markdown index 93779e54bc2d2a..eb98328fcebd66 100644 --- a/doc/api/tls.markdown +++ b/doc/api/tls.markdown @@ -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 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'