This repository has been archived by the owner on Oct 16, 2021. It is now read-only.
forked from nodejs/node-v0.x-archive
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tls: add
options
argument to createSecurePair
Helps in implementation of nodejs#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: nodejs/node#2441 Reviewed-By: Fedor Indutny <[email protected]>
- Loading branch information
1 parent
f661927
commit e8e6227
Showing
4 changed files
with
34 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'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); | ||
}); |