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 11#!/usr/bin/env node
22
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+
320import { ConsoleLogger , LogId } from "./common/logger.js" ;
421import { config } from "./common/config.js" ;
522import crypto from "crypto" ;
@@ -89,7 +106,6 @@ main().catch((error: unknown) => {
89106} ) ;
90107
91108function assertFIPSMode ( ) : void | never {
92- let fipsError : Error | undefined = undefined ;
93109 if ( config . tlsFIPSMode ) {
94110 if ( ! fipsError && ! crypto . getFips ( ) ) {
95111 fipsError = new Error ( "FIPS mode not enabled despite requested." ) ;
You can’t perform that action at this time.
0 commit comments