Sam Roberts
8 years ago
committed by
Myles Borins
No known key found for this signature in database
GPG Key ID: 933B01F40B5CA946
3 changed files with
18 additions and
3 deletions
doc/api/tls.md
lib/_tls_wrap.js
test/parallel/test-tls-socket-default-options.js
@ -483,7 +483,12 @@ added: v0.11.4
will be emitted on the socket before establishing a secure communication
will be emitted on the socket before establishing a secure communication
* `secureContext` : Optional TLS context object created with
* `secureContext` : Optional TLS context object created with
[`tls.createSecureContext()`][]. If a `secureContext` is _not_ provided, one
[`tls.createSecureContext()`][]. If a `secureContext` is _not_ provided, one
will be created by calling [`tls.createSecureContext()`][] with no options.
will be created by passing the entire `options` object to
`tls.createSecureContext()` . *Note* : In effect, all
[`tls.createSecureContext()`][] options can be provided, but they will be
_completely ignored_ unless the `secureContext` option is missing.
* ...: Optional [`tls.createSecureContext()`][] options can be provided, see
the `secureContext` option for more information.
Construct a new `tls.TLSSocket` object from an existing TCP socket.
Construct a new `tls.TLSSocket` object from an existing TCP socket.
@ -355,7 +355,7 @@ TLSSocket.prototype._wrapHandle = function(wrap) {
// Wrap socket's handle
// Wrap socket's handle
var context = options . secureContext ||
var context = options . secureContext ||
options . credentials ||
options . credentials ||
tls . createSecureContext ( ) ;
tls . createSecureContext ( options ) ;
res = tls_wrap . wrap ( handle . _ externalStream ,
res = tls_wrap . wrap ( handle . _ externalStream ,
context . context ,
context . context ,
! ! options . isServer ) ;
! ! options . isServer ) ;
@ -1,7 +1,7 @@
'use strict' ;
'use strict' ;
const common = require ( '../common' ) ;
const common = require ( '../common' ) ;
// Test a directly created TLS socket support s no options, and empty options.
// Test directly created TLS sockets and options.
const assert = require ( 'assert' ) ;
const assert = require ( 'assert' ) ;
const join = require ( 'path' ) . join ;
const join = require ( 'path' ) . join ;
@ -26,6 +26,16 @@ test({secureContext: tls.createSecureContext({ca: keys.agent1.ca})}, (err) => {
assert . ifError ( err ) ;
assert . ifError ( err ) ;
} ) ;
} ) ;
test ( { ca : keys . agent1 . ca } , ( err ) => {
assert . ifError ( err ) ;
} ) ;
// Secure context options, like ca, are ignored if a sec ctx is explicitly
// provided.
test ( { secureContext : tls . createSecureContext ( ) , ca : keys . agent1 . ca } , ( err ) => {
assert . strictEqual ( err . message , 'unable to verify the first certificate' ) ;
} ) ;
function test ( client , callback ) {
function test ( client , callback ) {
callback = common . mustCall ( callback ) ;
callback = common . mustCall ( callback ) ;
connect ( {
connect ( {