molnarg / node-http2

An HTTP/2 client and server implementation for node.js
MIT License
1.78k stars 186 forks source link

newSession / resumeSession events aren't fired #246

Closed hexadecatrienoic closed 7 years ago

hexadecatrienoic commented 7 years ago

I have the following TLS session handling code:

var secureServer = http2.createServer(options, requestHandler);
const tlsSessionStore = {};
secureServer.on('newSession', function(id, data, cb) {
    tlsSessionStore[id.toString("hex")] = data;
    cb();
});
secureServer.on('resumeSession', function(id, cb) {
    cb(null, tlsSessionStore[id.toString("hex")] || null);
});
secureServer.listen(443, '0.0.0.0');

This doesn't work with the http2 module (tickets work fine):

% openssl s_client -reconnect -state -prexit -connect <server>:443 2> /dev/null|grep -P "(New|Reused)"
New, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Reused, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Reused, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Reused, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Reused, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Reused, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256

% openssl s_client -reconnect -state -prexit -no_ticket -connect <server>:443 2> /dev/null|grep -P "(New|Reused)"
New, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
New, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
New, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
New, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
New, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
New, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256

This works fine with the https module:

% openssl s_client -reconnect -state -prexit -connect <server>:443 2> /dev/null|grep -P "(New|Reused)"
New, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Reused, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Reused, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Reused, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Reused, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Reused, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256

% openssl s_client -reconnect -state -prexit -no_ticket -connect <server>:443 2> /dev/null|grep -P "(New|Reused)"
New, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Reused, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Reused, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Reused, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Reused, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Reused, TLSv1.2, Cipher is ECDHE-RSA-AES128-GCM-SHA256
hexadecatrienoic commented 7 years ago

This issue has been resolved in the official HTTP/2 API.