@@ -84,9 +84,12 @@ const {
8484 getAllowUnauthorized,
8585} = require ( 'internal/options' ) ;
8686const {
87+ validateBoolean,
8788 validateBuffer,
8889 validateCallback,
90+ validateFunction,
8991 validateInt32,
92+ validateNumber,
9093 validateObject,
9194 validateString,
9295 validateUint32,
@@ -468,10 +471,8 @@ function TLSSocket(socket, opts) {
468471 process . emitWarning ( 'Enabling --trace-tls can expose sensitive data in ' +
469472 'the resulting log.' ) ;
470473 }
471- } else if ( typeof enableTrace !== 'boolean' ) {
472- throw new ERR_INVALID_ARG_TYPE (
473- 'options.enableTrace' , 'boolean' , enableTrace ) ;
474- }
474+ } else
475+ validateBoolean ( enableTrace , 'options.enableTrace' ) ;
475476
476477 if ( tlsOptions . ALPNProtocols )
477478 tls . convertALPNProtocols ( tlsOptions . ALPNProtocols , tlsOptions ) ;
@@ -783,11 +784,7 @@ TLSSocket.prototype._init = function(socket, wrap) {
783784 }
784785
785786 if ( options . pskCallback && ssl . enablePskCallback ) {
786- if ( typeof options . pskCallback !== 'function' ) {
787- throw new ERR_INVALID_ARG_TYPE ( 'pskCallback' ,
788- 'function' ,
789- options . pskCallback ) ;
790- }
787+ validateFunction ( options . pskCallback , 'pskCallback' ) ;
791788
792789 ssl [ kOnPskExchange ] = options . isServer ?
793790 onPskServerCallback : onPskClientCallback ;
@@ -796,13 +793,7 @@ TLSSocket.prototype._init = function(socket, wrap) {
796793 ssl . enablePskCallback ( ) ;
797794
798795 if ( options . pskIdentityHint ) {
799- if ( typeof options . pskIdentityHint !== 'string' ) {
800- throw new ERR_INVALID_ARG_TYPE (
801- 'options.pskIdentityHint' ,
802- 'string' ,
803- options . pskIdentityHint
804- ) ;
805- }
796+ validateString ( options . pskIdentityHint , 'options.pskIdentityHint' ) ;
806797 ssl . setPskIdentityHint ( options . pskIdentityHint ) ;
807798 }
808799 }
@@ -1215,10 +1206,7 @@ function Server(options, listener) {
12151206 this [ kPskCallback ] = options . pskCallback ;
12161207 this [ kPskIdentityHint ] = options . pskIdentityHint ;
12171208
1218- if ( typeof this [ kHandshakeTimeout ] !== 'number' ) {
1219- throw new ERR_INVALID_ARG_TYPE (
1220- 'options.handshakeTimeout' , 'number' , options . handshakeTimeout ) ;
1221- }
1209+ validateNumber ( this [ kHandshakeTimeout ] , 'options.handshakeTimeout' ) ;
12221210
12231211 if ( this [ kSNICallback ] && typeof this [ kSNICallback ] !== 'function' ) {
12241212 throw new ERR_INVALID_ARG_TYPE (
0 commit comments