{"record":{"id":"9859151ad144f227","repo":"denoland/deno","slug":"err-crypto-fips-forced","errorCode":"ERR_CRYPTO_FIPS_FORCED","errorMessage":"Cannot set FIPS mode, it was forced with --force-fips at startup.","messagePattern":"Cannot set FIPS mode, it was forced with --force-fips at startup\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/crypto.ts","lineNumber":364,"sourceCode":"  options?: TransformOptions,\n) {\n  return Hmac_(hmac, key, options);\n}\n\nfunction createSign(algorithm: string, options?: WritableOptions): Sign {\n  return new Sign(algorithm, options);\n}\n\nfunction createVerify(algorithm: string, options?: WritableOptions): Verify {\n  return new Verify(algorithm, options);\n}\n\nfunction setFipsForced(val: boolean) {\n  if (val) {\n    return;\n  }\n\n  throw new ERR_CRYPTO_FIPS_FORCED();\n}\n\nfunction getFipsForced() {\n  return 1;\n}\n\nObjectDefineProperty(constants, \"defaultCipherList\", {\n  __proto__: null,\n  value: getOptionValue(\"--tls-cipher-list\"),\n});\n\nconst getDiffieHellman = createDiffieHellmanGroup;\n\nconst getFips = fipsForced ? getFipsForced : getFipsCrypto;\nconst setFips = fipsForced ? setFipsForced : setFipsCrypto;\n\nconst sign = signOneShot;\nconst verify = verifyOneShot;","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/crypto.ts#L346-L382","documentation":"When the runtime starts with --force-fips, crypto.setFips is wired to setFipsForced(). In that mode setFips(true) is a no-op, but setFips(false) throws ERR_CRYPTO_FIPS_FORCED, because FIPS mode cannot be disabled after it was forced at startup.","triggerScenarios":"crypto.setFips(false) in an application run with the --force-fips flag. Startup scripts that toggle FIPS mode based on an environment setting while the flag is also present. A shared library that calls setFips(process.env.FIPS === '1').","commonSituations":"Compliance environments where FIPS is forced, plus application code that manages FIPS itself. Config drift between a forced flag and a runtime toggle. Code ported from a non-FIPS environment.","solutions":["Remove the setFips(false) call, or gate it on the forced flag.","Restart the process without --force-fips when FIPS is not required.","Treat FIPS as a startup-time decision; do not toggle it at runtime."],"exampleFix":"// before\nif (!fipsEnabled) crypto.setFips(false);\n\n// after\n// FIPS was forced at startup; do not disable at runtime\nif (!fipsEnabled && !process.execArgv.includes('--force-fips')) crypto.setFips(false);","handlingStrategy":"try-catch","validationCode":"const fipsForced = process.execArgv.some((a) => a.startsWith('--force-fips'));\nif (!fipsForced) crypto.setFips(enabled);","typeGuard":null,"tryCatchPattern":"try { crypto.setFips(enabled); } catch (e) { if (e.code === 'ERR_CRYPTO_FIPS_FORCED') { /* FIPS is forced at startup; leave it on */ } else throw e; }","preventionTips":["Decide FIPS mode at process start only; remove runtime toggles.","Check crypto.getFips() before any setFips() call."],"tags":["crypto","fips","startup-config"],"backgroundTag":"fips-mode","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}