• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Setting NODE_EXTRA_CA_CERTS to non-existent file emits a warning
2
3'use strict';
4const common = require('../common');
5
6if (!common.hasCrypto)
7  common.skip('missing crypto');
8
9const assert = require('assert');
10const fixtures = require('../common/fixtures');
11const fork = require('child_process').fork;
12const tls = require('tls');
13
14if (process.env.CHILD) {
15  // This will try to load the extra CA certs, and emit a warning when it fails.
16  return tls.createServer({});
17}
18
19const env = {
20  ...process.env,
21  CHILD: 'yes',
22  NODE_EXTRA_CA_CERTS: `${fixtures.fixturesDir}/no-such-file-exists-��`,
23};
24
25const opts = {
26  env: env,
27  silent: true,
28};
29let stderr = '';
30
31fork(__filename, opts)
32  .on('exit', common.mustCall(function(status) {
33    // Check that client succeeded in connecting.
34    assert.strictEqual(status, 0);
35  }))
36  .on('close', common.mustCall(function() {
37    // TODO(addaleax): Make `SafeGetenv` work like `process.env`
38    // encoding-wise
39    if (!common.isWindows) {
40      const re = /Warning: Ignoring extra certs from.*no-such-file-exists-��.* load failed:.*No such file or directory/;
41      assert(re.test(stderr), stderr);
42    }
43  }))
44  .stderr.setEncoding('utf8').on('data', function(str) {
45    stderr += str;
46  });
47