GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tls: new tls.TLSSocket() supports sec ctx options · nodejs/node@7cad561

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • tls.md
  • lib
    • _tls_wrap.js
  • test/parallel
    • test-tls-socket-default-options.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/tls.md‎

Copy file name to clipboardExpand all lines: doc/api/tls.md
+6-1Lines changed: 6 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,12 @@ added: v0.11.4
483483
will be emitted on the socket before establishing a secure communication
484484
* `secureContext`: Optional TLS context object created with
485485
[`tls.createSecureContext()`][]. If a `secureContext` is _not_ provided, one
486-
will be created by calling [`tls.createSecureContext()`][] with no options.
486+
will be created by passing the entire `options` object to
487+
`tls.createSecureContext()`. *Note*: In effect, all
488+
[`tls.createSecureContext()`][] options can be provided, but they will be
489+
_completely ignored_ unless the `secureContext` option is missing.
490+
* ...: Optional [`tls.createSecureContext()`][] options can be provided, see
491+
the `secureContext` option for more information.
487492

488493
Construct a new `tls.TLSSocket` object from an existing TCP socket.
489494

Collapse file

‎lib/_tls_wrap.js‎

Copy file name to clipboardExpand all lines: lib/_tls_wrap.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ TLSSocket.prototype._wrapHandle = function(wrap) {
355355
// Wrap socket's handle
356356
var context = options.secureContext ||
357357
options.credentials ||
358-
tls.createSecureContext();
358+
tls.createSecureContext(options);
359359
res = tls_wrap.wrap(handle._externalStream,
360360
context.context,
361361
!!options.isServer);
Collapse file

‎test/parallel/test-tls-socket-default-options.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-tls-socket-default-options.js
+11-1Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22
const common = require('../common');
33

4-
// Test a directly created TLS socket supports no options, and empty options.
4+
// Test directly created TLS sockets and options.
55

66
const assert = require('assert');
77
const join = require('path').join;
@@ -26,6 +26,16 @@ test({secureContext: tls.createSecureContext({ca: keys.agent1.ca})}, (err) => {
2626
assert.ifError(err);
2727
});
2828

29+
test({ca: keys.agent1.ca}, (err) => {
30+
assert.ifError(err);
31+
});
32+
33+
// Secure context options, like ca, are ignored if a sec ctx is explicitly
34+
// provided.
35+
test({secureContext: tls.createSecureContext(), ca: keys.agent1.ca}, (err) => {
36+
assert.strictEqual(err.message, 'unable to verify the first certificate');
37+
});
38+
2939
function test(client, callback) {
3040
callback = common.mustCall(callback);
3141
connect({

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.