mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
c879c9a5c6
Allows env vars to be passed through to child processes. This is needed for things like NODE_TEST_DIR or LD_LIBRARY_PATH if testing the shared library. PR-URL: https://github.com/nodejs/node/pull/14822 Refs: https://github.com/nodejs/node/pull/13390 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com>
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
// Certs in NODE_EXTRA_CA_CERTS are used for TLS peer validation
|
|
|
|
'use strict';
|
|
const common = require('../common');
|
|
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const tls = require('tls');
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
const { fork } = require('child_process');
|
|
|
|
if (process.env.CHILD) {
|
|
const copts = {
|
|
port: process.env.PORT,
|
|
checkServerIdentity: common.mustCall(),
|
|
};
|
|
const client = tls.connect(copts, common.mustCall(function() {
|
|
client.end('hi');
|
|
}));
|
|
return;
|
|
}
|
|
|
|
const options = {
|
|
key: fixtures.readKey('agent1-key.pem'),
|
|
cert: fixtures.readKey('agent1-cert.pem'),
|
|
};
|
|
|
|
const server = tls.createServer(options, common.mustCall(function(s) {
|
|
s.end('bye');
|
|
server.close();
|
|
})).listen(0, common.mustCall(function() {
|
|
const env = Object.assign({}, process.env, {
|
|
CHILD: 'yes',
|
|
PORT: this.address().port,
|
|
NODE_EXTRA_CA_CERTS: fixtures.path('keys', 'ca1-cert.pem')
|
|
});
|
|
|
|
fork(__filename, { env: env }).on('exit', common.mustCall(function(status) {
|
|
assert.strictEqual(status, 0, 'client did not succeed in connecting');
|
|
}));
|
|
}));
|