mirror of
https://github.com/nodejs/node.git
synced 2025-05-10 17:57:53 +00:00

Assert the server name directly in the `SNICallback`, since `common.mustCall()` already guarantees that the callback is called exactly once, making `process.on('exit')` unnecessary. PR-URL: https://github.com/nodejs/node/pull/17836 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
26 lines
702 B
JavaScript
26 lines
702 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const tls = require('tls');
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
const sslcontext = tls.createSecureContext({
|
|
cert: fixtures.readSync('test_cert.pem'),
|
|
key: fixtures.readSync('test_key.pem')
|
|
});
|
|
|
|
const pair = tls.createSecurePair(sslcontext, true, false, false, {
|
|
SNICallback: common.mustCall((servername, cb) => {
|
|
assert.strictEqual(servername, 'www.google.com');
|
|
})
|
|
});
|
|
|
|
// captured traffic from browser's request to https://www.google.com
|
|
const sslHello = fixtures.readSync('google_ssl_hello.bin');
|
|
|
|
pair.encrypted.write(sslHello);
|