File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env node
2
2
3
+ let fipsError : Error | undefined ;
4
+ function enableFipsIfRequested ( ) : void {
5
+ if ( process . argv . includes ( "--tlsFIPSMode" ) ) {
6
+ // FIPS mode should be enabled before we run any other code, including any dependencies.
7
+ // We still wrap this into a function so we can also call it immediately after
8
+ // entering the snapshot main function.
9
+ try {
10
+ // eslint-disable-next-line
11
+ require ( "crypto" ) . setFips ( 1 ) ;
12
+ } catch ( err : unknown ) {
13
+ fipsError ??= err as Error ;
14
+ }
15
+ }
16
+ }
17
+
18
+ enableFipsIfRequested ( ) ;
19
+
3
20
import { ConsoleLogger , LogId } from "./common/logger.js" ;
4
21
import { config } from "./common/config.js" ;
5
22
import crypto from "crypto" ;
@@ -89,7 +106,6 @@ main().catch((error: unknown) => {
89
106
} ) ;
90
107
91
108
function assertFIPSMode ( ) : void | never {
92
- let fipsError : Error | undefined = undefined ;
93
109
if ( config . tlsFIPSMode ) {
94
110
if ( ! fipsError && ! crypto . getFips ( ) ) {
95
111
fipsError = new Error ( "FIPS mode not enabled despite requested." ) ;
You can’t perform that action at this time.
0 commit comments