1'use strict'; 2 3const common = require('../common'); 4if (!common.hasCrypto) 5 common.skip('missing crypto'); 6 7if (!common.hasOpenSSL3) 8 common.skip('this test requires OpenSSL 3.x'); 9 10const assert = require('node:assert/strict'); 11const crypto = require('node:crypto'); 12 13if (common.isMainThread) { 14 // TODO(richardlau): Decide if `crypto.setFips` should error if the 15 // provider named "fips" is not available. 16 crypto.setFips(1); 17 crypto.randomBytes(20, common.mustCall((err) => { 18 // crypto.randomBytes should either succeed or fail but not hang. 19 if (err) { 20 assert.match(err.message, /digital envelope routines::unsupported/); 21 const expected = /random number generator::unable to fetch drbg/; 22 assert(err.opensslErrorStack.some((msg) => expected.test(msg)), 23 `did not find ${expected} in ${err.opensslErrorStack}`); 24 } 25 })); 26} 27 28{ 29 // Startup test. Should not hang. 30 const { path } = require('../common/fixtures'); 31 const { spawnSync } = require('node:child_process'); 32 const baseConf = path('openssl3-conf', 'base_only.cnf'); 33 const cp = spawnSync(process.execPath, 34 [ `--openssl-config=${baseConf}`, '-p', '"hello"' ], 35 { encoding: 'utf8' }); 36 assert(common.nodeProcessAborted(cp.status, cp.signal), 37 `process did not abort, code:${cp.status} signal:${cp.signal}`); 38} 39