mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 09:02:40 +00:00

Helps in implementation of #6204, where some options passed to `createSecurePair()` are ignored before this patch. These options are very helpful if someone wants to pass `options.servername` or `options.SNICallback` to securepair. PR-URL: https://github.com/nodejs/node/pull/2441 Reviewed-By: Fedor Indutny <fedor@indutny.com>
28 lines
789 B
JavaScript
28 lines
789 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const tls = require('tls');
|
|
|
|
const sslcontext = tls.createSecureContext({
|
|
cert: fs.readFileSync(common.fixturesDir + '/test_cert.pem'),
|
|
key: fs.readFileSync(common.fixturesDir + '/test_key.pem')
|
|
});
|
|
|
|
var catchedServername;
|
|
const pair = tls.createSecurePair(sslcontext, true, false, false, {
|
|
SNICallback: common.mustCall(function(servername, cb) {
|
|
catchedServername = servername;
|
|
})
|
|
});
|
|
|
|
// captured traffic from browser's request to https://www.google.com
|
|
const sslHello = fs.readFileSync(common.fixturesDir + '/google_ssl_hello.bin');
|
|
|
|
pair.encrypted.write(sslHello);
|
|
|
|
process.on('exit', function() {
|
|
assert.strictEqual('www.google.com', catchedServername);
|
|
});
|