@@ -37,8 +37,9 @@ function testHelper(stream, args, expectedOutput, cmd, env) {
3737 env : env
3838 } ) ;
3939
40- console . error ( 'Spawned child [pid:' + child . pid + '] with cmd ' +
41- cmd + ' and args \'' + args + '\'' ) ;
40+ console . error ( 'Spawned child [pid:' + child . pid + '] with cmd \'' +
41+ cmd + '\' expect %j with args \'' + args + '\'' +
42+ ' OPENSSL_CONF=%j' , expectedOutput , env . OPENSSL_CONF ) ;
4243
4344 function childOk ( child ) {
4445 console . error ( 'Child #' + ++ num_children_ok +
@@ -92,10 +93,26 @@ testHelper(
9293 compiledWithFips ( ) ? FIPS_ENABLED : FIPS_DISABLED ,
9394 'require("crypto").fips' ,
9495 process . env ) ;
95- // OPENSSL_CONF should _not_ be able to turn on FIPS mode
96+
97+ // OPENSSL_CONF should be able to turn on FIPS mode
9698testHelper (
9799 'stdout' ,
98100 [ ] ,
101+ compiledWithFips ( ) ? FIPS_ENABLED : FIPS_DISABLED ,
102+ 'require("crypto").fips' ,
103+ addToEnv ( 'OPENSSL_CONF' , CNF_FIPS_ON ) ) ;
104+
105+ // --openssl-config option should override OPENSSL_CONF
106+ testHelper (
107+ 'stdout' ,
108+ [ `--openssl-config=${ CNF_FIPS_ON } ` ] ,
109+ compiledWithFips ( ) ? FIPS_ENABLED : FIPS_DISABLED ,
110+ 'require("crypto").fips' ,
111+ addToEnv ( 'OPENSSL_CONF' , CNF_FIPS_OFF ) ) ;
112+
113+ testHelper (
114+ 'stdout' ,
115+ [ `--openssl-config=${ CNF_FIPS_OFF } ` ] ,
99116 FIPS_DISABLED ,
100117 'require("crypto").fips' ,
101118 addToEnv ( 'OPENSSL_CONF' , CNF_FIPS_ON ) ) ;
@@ -107,6 +124,7 @@ testHelper(
107124 compiledWithFips ( ) ? FIPS_ENABLED : OPTION_ERROR_STRING ,
108125 'require("crypto").fips' ,
109126 process . env ) ;
127+
110128// OPENSSL_CONF should _not_ make a difference to --enable-fips
111129testHelper (
112130 compiledWithFips ( ) ? 'stdout' : 'stderr' ,
@@ -122,6 +140,7 @@ testHelper(
122140 compiledWithFips ( ) ? FIPS_ENABLED : OPTION_ERROR_STRING ,
123141 'require("crypto").fips' ,
124142 process . env ) ;
143+
125144// Using OPENSSL_CONF should not make a difference to --force-fips
126145testHelper (
127146 compiledWithFips ( ) ? 'stdout' : 'stderr' ,
0 commit comments