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 @@ -69,7 +69,10 @@ const {
69
69
ERR_TLS_INVALID_STATE
70
70
} = codes ;
71
71
const { onpskexchange : kOnPskExchange } = internalBinding ( 'symbols' ) ;
72
- const { getOptionValue } = require ( 'internal/options' ) ;
72
+ const {
73
+ getOptionValue,
74
+ getAllowUnauthorized,
75
+ } = require ( 'internal/options' ) ;
73
76
const {
74
77
validateString,
75
78
validateBuffer,
@@ -1539,22 +1542,12 @@ function onConnectEnd() {
1539
1542
}
1540
1543
}
1541
1544
1542
- let warnOnAllowUnauthorized = true ;
1543
-
1544
1545
// Arguments: [port,] [host,] [options,] [cb]
1545
1546
exports . connect = function connect ( ...args ) {
1546
1547
args = normalizeConnectArgs ( args ) ;
1547
1548
let options = args [ 0 ] ;
1548
1549
const cb = args [ 1 ] ;
1549
- const allowUnauthorized = process . env . NODE_TLS_REJECT_UNAUTHORIZED === '0' ;
1550
-
1551
- if ( allowUnauthorized && warnOnAllowUnauthorized ) {
1552
- warnOnAllowUnauthorized = false ;
1553
- process . emitWarning ( 'Setting the NODE_TLS_REJECT_UNAUTHORIZED ' +
1554
- 'environment variable to \'0\' makes TLS connections ' +
1555
- 'and HTTPS requests insecure by disabling ' +
1556
- 'certificate verification.' ) ;
1557
- }
1550
+ const allowUnauthorized = getAllowUnauthorized ( ) ;
1558
1551
1559
1552
options = {
1560
1553
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