Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2296a4f

Browse filesBrowse files
socketpairrvagg
authored andcommitted
tls: add options argument to createSecurePair
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: #2441 Reviewed-By: Fedor Indutny <fedor@indutny.com>
1 parent 5e0759f commit 2296a4f
Copy full SHA for 2296a4f

File tree

Expand file treeCollapse file tree

4 files changed

+34
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+34
-3
lines changed
Open diff view settings
Collapse file

‎doc/api/tls.markdown‎

Copy file name to clipboardExpand all lines: doc/api/tls.markdown
+3-1Lines changed: 3 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ publicly trusted list of CAs as given in
511511
<http://mxr.mozilla.org/mozilla/source/security/nss/lib/ckfw/builtins/certdata.txt>.
512512

513513

514-
## tls.createSecurePair([context][, isServer][, requestCert][, rejectUnauthorized])
514+
## tls.createSecurePair([context][, isServer][, requestCert][, rejectUnauthorized][, options])
515515

516516
Creates a new secure pair object with two streams, one of which reads/writes
517517
encrypted data, and one reads/writes cleartext data.
@@ -530,6 +530,8 @@ and the cleartext one is used as a replacement for the initial encrypted stream.
530530
automatically reject clients with invalid certificates. Only applies to
531531
servers with `requestCert` enabled.
532532

533+
- `options`: An object with common SSL options. See [tls.TLSSocket][].
534+
533535
`tls.createSecurePair()` returns a SecurePair object with `cleartext` and
534536
`encrypted` stream properties.
535537

Collapse file

‎lib/_tls_legacy.js‎

Copy file name to clipboardExpand all lines: lib/_tls_legacy.js
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,11 +761,13 @@ function securePairNT(self, options) {
761761
exports.createSecurePair = function(context,
762762
isServer,
763763
requestCert,
764-
rejectUnauthorized) {
764+
rejectUnauthorized,
765+
options) {
765766
var pair = new SecurePair(context,
766767
isServer,
767768
requestCert,
768-
rejectUnauthorized);
769+
rejectUnauthorized,
770+
options);
769771
return pair;
770772
};
771773

Collapse file

‎test/fixtures/google_ssl_hello.bin‎

Copy file name to clipboard
517 Bytes
Binary file not shown.
Collapse file
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const assert = require('assert');
5+
const fs = require('fs');
6+
const tls = require('tls');
7+
8+
const sslcontext = tls.createSecureContext({
9+
cert: fs.readFileSync(common.fixturesDir + '/test_cert.pem'),
10+
key: fs.readFileSync(common.fixturesDir + '/test_key.pem')
11+
});
12+
13+
var catchedServername;
14+
const pair = tls.createSecurePair(sslcontext, true, false, false, {
15+
SNICallback: common.mustCall(function(servername, cb) {
16+
catchedServername = servername;
17+
})
18+
});
19+
20+
// captured traffic from browser's request to https://www.google.com
21+
const sslHello = fs.readFileSync(common.fixturesDir + '/google_ssl_hello.bin');
22+
23+
pair.encrypted.write(sslHello);
24+
25+
process.on('exit', function() {
26+
assert.strictEqual('www.google.com', catchedServername);
27+
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.