@@ -343,6 +343,12 @@ function initRead(tlsSocket, socket) {
343
343
344
344
function TLSSocket ( socket , opts ) {
345
345
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
+ }
346
352
347
353
if ( tlsOptions . ALPNProtocols )
348
354
tls . convertALPNProtocols ( tlsOptions . ALPNProtocols , tlsOptions ) ;
@@ -397,6 +403,9 @@ function TLSSocket(socket, opts) {
397
403
this . readable = true ;
398
404
this . writable = true ;
399
405
406
+ if ( enableTrace && this . _handle )
407
+ this . _handle . enableTrace ( ) ;
408
+
400
409
// Read on next tick so the caller has a chance to setup listeners
401
410
process . nextTick ( initRead , this , socket ) ;
402
411
}
@@ -872,10 +881,9 @@ function tlsConnectionListener(rawSocket) {
872
881
rejectUnauthorized : this . rejectUnauthorized ,
873
882
handshakeTimeout : this [ kHandshakeTimeout ] ,
874
883
ALPNProtocols : this . ALPNProtocols ,
875
- SNICallback : this [ kSNICallback ] || SNICallback
884
+ SNICallback : this [ kSNICallback ] || SNICallback ,
885
+ enableTrace : this [ kEnableTrace ]
876
886
} ) ;
877
- if ( this [ kEnableTrace ] && socket . _handle )
878
- socket . _handle . enableTrace ( ) ;
879
887
880
888
socket . on ( 'secure' , onServerSocketSecure ) ;
881
889
@@ -997,13 +1005,7 @@ function Server(options, listener) {
997
1005
this . on ( 'secureConnection' , listener ) ;
998
1006
}
999
1007
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 ;
1007
1009
}
1008
1010
1009
1011
Object . setPrototypeOf ( Server . prototype , net . Server . prototype ) ;
@@ -1364,7 +1366,8 @@ exports.connect = function connect(...args) {
1364
1366
rejectUnauthorized : options . rejectUnauthorized !== false ,
1365
1367
session : options . session ,
1366
1368
ALPNProtocols : options . ALPNProtocols ,
1367
- requestOCSP : options . requestOCSP
1369
+ requestOCSP : options . requestOCSP ,
1370
+ enableTrace : options . enableTrace
1368
1371
} ) ;
1369
1372
1370
1373
tlssock [ kConnectOptions ] = options ;
0 commit comments