-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
tls: do not crash on STARTTLS when OCSP requested #10706
Changes from 6 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use strict'; | ||
|
||
// Test asynchronous SNI+OCSP on TLSSocket created with `server` set to | ||
// `net.Server` instead of `tls.Server` | ||
|
||
const common = require('../common'); | ||
|
||
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. https://github.com/nodejs/node/blob/master/doc/guides/writing-tests.md#test-structure
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. Ack |
||
if (!common.hasCrypto) { | ||
common.skip('missing crypto'); | ||
return; | ||
} | ||
|
||
const assert = require('assert'); | ||
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. sort requires 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. Ack |
||
const fs = require('fs'); | ||
const net = require('net'); | ||
const tls = require('tls'); | ||
|
||
const key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'); | ||
const cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'); | ||
|
||
const server = net.createServer(common.mustCall((s) => { | ||
const tlsSocket = new tls.TLSSocket(s, { | ||
isServer: true, | ||
server: server, | ||
|
||
secureContext: tls.createSecureContext({ | ||
key: key, | ||
cert: cert | ||
}), | ||
|
||
SNICallback: common.mustCall((hostname, callback) => { | ||
assert.strictEqual(hostname, 'test.test'); | ||
|
||
callback(null, null); | ||
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.
Is 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. Yes, it is valid and it should be valid. |
||
}) | ||
}); | ||
|
||
tlsSocket.on('secure', common.mustCall(() => { | ||
tlsSocket.end(); | ||
server.close(); | ||
})); | ||
})).listen(0, () => { | ||
const opts = { | ||
servername: 'test.test', | ||
port: server.address().port, | ||
rejectUnauthorized: false, | ||
requestOCSP: true | ||
}; | ||
|
||
tls.connect(opts, function() { | ||
this.end(); | ||
}); | ||
}); |
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.
Consider giving one or two examples of properties that won't be there.