Skip to content

Commit 096ad5b

Browse files
orgadsclaude
andcommitted
doc: document that an empty OPENSSL_CONF skips config loading
A default OpenSSL configuration file that exists but cannot be read is fatal at startup: CONF_MFLAGS_IGNORE_MISSING_FILE only covers ENOENT and ENOTDIR, so a container that mounts /etc/ssl inaccessible to the user Node.js runs as cannot start at all. OpenSSL skips config loading entirely when OPENSSL_CONF is set to an empty value, which gets past this, but that was undocumented. Say so, including that no configuration is applied, FIPS setup included. Refs: nodejs#62230 Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: Orgad Shaneh <[email protected]>
1 parent 9caf674 commit 096ad5b

3 files changed

Lines changed: 55 additions & 2 deletions

File tree

‎doc/api/cli.md‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4262,8 +4262,15 @@ added: v6.11.0
42624262
Load an OpenSSL configuration file on startup. The file can be used as part of
42634263
a [FIPS mode][] configuration.
42644264

4265+
If the variable is set to an empty value, Node.js starts without loading any
4266+
OpenSSL configuration file. This is a way past a default configuration file
4267+
that exists but cannot be read, for example when `/etc/ssl` is not accessible
4268+
to the user Node.js runs as, which is otherwise fatal at startup. No
4269+
configuration is applied in that case, including any [FIPS mode][] setup the
4270+
file would have performed.
4271+
42654272
If the [`--openssl-config`][] command-line option is used, the environment
4266-
variable is ignored.
4273+
variable is ignored, and an empty value has no effect.
42674274

42684275
### `SSL_CERT_DIR=dir`
42694276

‎doc/node.1‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2375,8 +2375,14 @@ environment variable is arbitrary.
23752375
.It Ev OPENSSL_CONF Ar file
23762376
Load an OpenSSL configuration file on startup. The file can be used as part of
23772377
a FIPS mode configuration.
2378+
If the variable is set to an empty value, Node.js starts without loading any
2379+
OpenSSL configuration file. This is a way past a default configuration file
2380+
that exists but cannot be read, for example when \fB/etc/ssl\fR is not accessible
2381+
to the user Node.js runs as, which is otherwise fatal at startup. No
2382+
configuration is applied in that case, including any FIPS mode setup the
2383+
file would have performed.
23782384
If the \fB--openssl-config\fR command-line option is used, the environment
2379-
variable is ignored.
2385+
variable is ignored, and an empty value has no effect.
23802386
.
23812387
.It Ev SSL_CERT_DIR Ar dir
23822388
If \fB--use-openssl-ca\fR is enabled, or if \fB--use-system-ca\fR is enabled on
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'use strict';
2+
3+
// A default OpenSSL configuration file that cannot be read is fatal, and an
4+
// empty OPENSSL_CONF is the documented way past it.
5+
// Refs: https://github.com/nodejs/node/issues/62230
6+
7+
const common = require('../common');
8+
const assert = require('node:assert');
9+
const { spawnSync } = require('node:child_process');
10+
11+
if (!common.hasCrypto)
12+
common.skip('missing crypto');
13+
if (!common.isLinux)
14+
common.skip('linux only');
15+
if (process.config.variables.node_shared_openssl)
16+
common.skip('shared openssl may read a different configuration file');
17+
18+
// Replace /etc/ssl with an empty tmpfs in a private mount namespace, where
19+
// openssl.cnf is a symlink loop: opening it then fails with ELOOP instead of
20+
// ENOENT, which OpenSSL ignores on its own. The namespace goes away with the
21+
// process, so the host /etc/ssl is left alone.
22+
const setup = 'mount -t tmpfs tmpfs /etc/ssl && ln -s openssl.cnf /etc/ssl/openssl.cnf';
23+
24+
if (spawnSync('unshare', ['-Urm', 'sh', '-c', setup]).status !== 0)
25+
common.skip('cannot set up an unprivileged user and mount namespace');
26+
27+
function run(env) {
28+
return spawnSync(
29+
'unshare',
30+
['-Urm', 'sh', '-c', `${setup} && exec "$0" -p 42`, process.execPath],
31+
{ encoding: 'utf8', env: { ...process.env, ...env } });
32+
}
33+
34+
const failed = run({});
35+
assert.notStrictEqual(failed.status, 0);
36+
assert.match(failed.stderr, /OpenSSL configuration error/);
37+
38+
const skipped = run({ OPENSSL_CONF: '' });
39+
assert.strictEqual(skipped.status, 0);
40+
assert.strictEqual(skipped.stdout.trim(), '42');

0 commit comments

Comments
 (0)