File tree 2 files changed +23
-13
lines changed
2 files changed +23
-13
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,10 @@ const {
70
70
ERR_TLS_INVALID_STATE
71
71
} = codes ;
72
72
const { onpskexchange : kOnPskExchange } = internalBinding ( 'symbols' ) ;
73
- const { getOptionValue } = require ( 'internal/options' ) ;
73
+ const {
74
+ getOptionValue,
75
+ getAllowUnauthorized,
76
+ } = require ( 'internal/options' ) ;
74
77
const {
75
78
validateString,
76
79
validateBuffer,
@@ -1540,22 +1543,12 @@ function onConnectEnd() {
1540
1543
}
1541
1544
}
1542
1545
1543
- let warnOnAllowUnauthorized = true ;
1544
-
1545
1546
// Arguments: [port,] [host,] [options,] [cb]
1546
1547
exports . connect = function connect ( ...args ) {
1547
1548
args = normalizeConnectArgs ( args ) ;
1548
1549
let options = args [ 0 ] ;
1549
1550
const cb = args [ 1 ] ;
1550
- const allowUnauthorized = process . env . NODE_TLS_REJECT_UNAUTHORIZED === '0' ;
1551
-
1552
- if ( allowUnauthorized && warnOnAllowUnauthorized ) {
1553
- warnOnAllowUnauthorized = false ;
1554
- process . emitWarning ( 'Setting the NODE_TLS_REJECT_UNAUTHORIZED ' +
1555
- 'environment variable to \'0\' makes TLS connections ' +
1556
- 'and HTTPS requests insecure by disabling ' +
1557
- 'certificate verification.' ) ;
1558
- }
1551
+ const allowUnauthorized = getAllowUnauthorized ( ) ;
1559
1552
1560
1553
options = {
1561
1554
rejectUnauthorized : ! allowUnauthorized ,
Original file line number Diff line number Diff line change 3
3
const { getOptions } = internalBinding ( 'options' ) ;
4
4
const { options, aliases } = getOptions ( ) ;
5
5
6
+ let warnOnAllowUnauthorized = true ;
7
+
6
8
function getOptionValue ( option ) {
7
9
const result = options . get ( option ) ;
8
10
if ( ! result ) {
@@ -11,8 +13,23 @@ function getOptionValue(option) {
11
13
return result . value ;
12
14
}
13
15
16
+ function getAllowUnauthorized ( ) {
17
+ const allowUnauthorized = process . env . NODE_TLS_REJECT_UNAUTHORIZED === '0' ;
18
+
19
+ if ( allowUnauthorized && warnOnAllowUnauthorized ) {
20
+ warnOnAllowUnauthorized = false ;
21
+ process . emitWarning (
22
+ 'Setting the NODE_TLS_REJECT_UNAUTHORIZED ' +
23
+ 'environment variable to \'0\' makes TLS connections ' +
24
+ 'and HTTPS requests insecure by disabling ' +
25
+ 'certificate verification.' ) ;
26
+ }
27
+ return allowUnauthorized ;
28
+ }
29
+
14
30
module . exports = {
15
31
options,
16
32
aliases,
17
- getOptionValue
33
+ getOptionValue,
34
+ getAllowUnauthorized,
18
35
} ;
You can’t perform that action at this time.
0 commit comments