Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 36.4k
tls: getTicketKeys()/setTicketKeys()#2227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -20,21 +20,37 @@ var serverCount = 0; | ||
| function createServer() { | ||
| var id = serverCount++; | ||
| var counter = 0; | ||
| var previousKey = null; | ||
| var server = tls.createServer({ | ||
| key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), | ||
| cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'), | ||
| ticketKeys: keys | ||
| }, function(c) { | ||
| serverLog.push(id); | ||
| c.end(); | ||
| counter++; | ||
| // Rotate ticket keys | ||
| if (counter === 1) { | ||
| previousKey = server.getTicketKeys(); | ||
| server.setTicketKeys(crypto.randomBytes(48)); | ||
| } else if (counter === 2) { | ||
| server.setTicketKeys(previousKey); | ||
| } else { | ||
| throw new Error('UNREACHABLE'); | ||
| } | ||
| }); | ||
| return server; | ||
| } | ||
| var servers = [ createServer(), createServer(), | ||
| createServer(), createServer(), | ||
| createServer(), createServer() ]; | ||
| var naturalServers = [ createServer(), createServer(), createServer() ]; | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this imply there are unnatural servers as well? MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, they are just clones :( | ||
| // 3x servers | ||
| var servers = naturalServers.concat(naturalServers).concat(naturalServers); | ||
| // Create one TCP server and balance sockets to multiple TLS server instances | ||
| var shared = net.createServer(function(c) { | ||
| @@ -54,7 +70,7 @@ function start(callback) { | ||
| session: sess, | ||
| rejectUnauthorized: false | ||
| }, function() { | ||
| sess = s.getSession() || sess; | ||
| sess = sess || s.getSession(); | ||
| ticketLog.push(s.getTLSTicket().toString('hex')); | ||
| }); | ||
| s.on('close', function() { | ||
| @@ -70,8 +86,14 @@ function start(callback) { | ||
| process.on('exit', function() { | ||
| assert.equal(ticketLog.length, serverLog.length); | ||
| for (var i = 0; i < serverLog.length - 1; i++) { | ||
| for (var i = 0; i < naturalServers.length - 1; i++) { | ||
| assert.notEqual(serverLog[i], serverLog[i + 1]); | ||
| assert.equal(ticketLog[i], ticketLog[i + 1]); | ||
| // 2nd connection should have different ticket | ||
| assert.notEqual(ticketLog[i], ticketLog[i + naturalServers.length]); | ||
| // 3rd connection should have the same ticket | ||
| assert.equal(ticketLog[i], ticketLog[i + naturalServers.length * 2]); | ||
| } | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps the second sentence is an irrelevant implementation detail?