tls: warn on NODE_TLS_REJECT_UNAUTHORIZED = '0'

Warn on the first request that sets the
NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0'.

PR-URL: https://github.com/nodejs/node/pull/21900
Refs: https://github.com/nodejs/node/issues/21774
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
cjihrig
2018-07-19 22:02:44 -04:00
parent 87f767160d
commit 3095eecc47
2 changed files with 20 additions and 1 deletions

View File

@@ -28,6 +28,14 @@ if (!common.hasCrypto)
// disable strict server certificate validation by the client
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
common.expectWarning(
'Warning',
'Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to \'0\' ' +
'makes TLS connections and HTTPS requests insecure by disabling ' +
'certificate verification.',
common.noWarnCode
);
const assert = require('assert');
const https = require('https');