mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
14aa313186
Make it so that the allow unauthorized warning can be easily reused by the QUIC impl once that lands. Extracted from https://github.com/nodejs/node/pull/32379 Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: https://github.com/nodejs/node/pull/32917 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
36 lines
841 B
JavaScript
36 lines
841 B
JavaScript
'use strict';
|
|
|
|
const { getOptions } = internalBinding('options');
|
|
const { options, aliases } = getOptions();
|
|
|
|
let warnOnAllowUnauthorized = true;
|
|
|
|
function getOptionValue(option) {
|
|
const result = options.get(option);
|
|
if (!result) {
|
|
return undefined;
|
|
}
|
|
return result.value;
|
|
}
|
|
|
|
function getAllowUnauthorized() {
|
|
const allowUnauthorized = process.env.NODE_TLS_REJECT_UNAUTHORIZED === '0';
|
|
|
|
if (allowUnauthorized && warnOnAllowUnauthorized) {
|
|
warnOnAllowUnauthorized = false;
|
|
process.emitWarning(
|
|
'Setting the NODE_TLS_REJECT_UNAUTHORIZED ' +
|
|
'environment variable to \'0\' makes TLS connections ' +
|
|
'and HTTPS requests insecure by disabling ' +
|
|
'certificate verification.');
|
|
}
|
|
return allowUnauthorized;
|
|
}
|
|
|
|
module.exports = {
|
|
options,
|
|
aliases,
|
|
getOptionValue,
|
|
getAllowUnauthorized,
|
|
};
|