@@ -343,6 +343,12 @@ function initRead(tlsSocket, socket) {
343343
344344function TLSSocket ( socket , opts ) {
345345 const tlsOptions = { ...opts } ;
346+ const enableTrace = tlsOptions . enableTrace ;
347+
348+ if ( typeof enableTrace !== 'boolean' && enableTrace != null ) {
349+ throw new ERR_INVALID_ARG_TYPE (
350+ 'options.enableTrace' , 'boolean' , enableTrace ) ;
351+ }
346352
347353 if ( tlsOptions . ALPNProtocols )
348354 tls . convertALPNProtocols ( tlsOptions . ALPNProtocols , tlsOptions ) ;
@@ -397,6 +403,9 @@ function TLSSocket(socket, opts) {
397403 this . readable = true ;
398404 this . writable = true ;
399405
406+ if ( enableTrace && this . _handle )
407+ this . _handle . enableTrace ( ) ;
408+
400409 // Read on next tick so the caller has a chance to setup listeners
401410 process . nextTick ( initRead , this , socket ) ;
402411}
@@ -872,10 +881,9 @@ function tlsConnectionListener(rawSocket) {
872881 rejectUnauthorized : this . rejectUnauthorized ,
873882 handshakeTimeout : this [ kHandshakeTimeout ] ,
874883 ALPNProtocols : this . ALPNProtocols ,
875- SNICallback : this [ kSNICallback ] || SNICallback
884+ SNICallback : this [ kSNICallback ] || SNICallback ,
885+ enableTrace : this [ kEnableTrace ]
876886 } ) ;
877- if ( this [ kEnableTrace ] && socket . _handle )
878- socket . _handle . enableTrace ( ) ;
879887
880888 socket . on ( 'secure' , onServerSocketSecure ) ;
881889
@@ -997,13 +1005,7 @@ function Server(options, listener) {
9971005 this . on ( 'secureConnection' , listener ) ;
9981006 }
9991007
1000- const enableTrace = options . enableTrace ;
1001- if ( typeof enableTrace === 'boolean' ) {
1002- this [ kEnableTrace ] = enableTrace ;
1003- } else if ( enableTrace != null ) {
1004- throw new ERR_INVALID_ARG_TYPE (
1005- 'options.enableTrace' , 'boolean' , enableTrace ) ;
1006- }
1008+ this [ kEnableTrace ] = options . enableTrace ;
10071009}
10081010
10091011Object . setPrototypeOf ( Server . prototype , net . Server . prototype ) ;
@@ -1364,7 +1366,8 @@ exports.connect = function connect(...args) {
13641366 rejectUnauthorized : options . rejectUnauthorized !== false ,
13651367 session : options . session ,
13661368 ALPNProtocols : options . ALPNProtocols ,
1367- requestOCSP : options . requestOCSP
1369+ requestOCSP : options . requestOCSP ,
1370+ enableTrace : options . enableTrace
13681371 } ) ;
13691372
13701373 tlssock [ kConnectOptions ] = options ;
0 commit comments