denoland/deno · error · Error
ERR_CRYPTO_FIPS_FORCED
ERR_CRYPTO_FIPS_FORCED
Error message
Cannot set FIPS mode, it was forced with --force-fips at startup.
What it means
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.
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.
Example fix
// before
if (!fipsEnabled) crypto.setFips(false);
// after
// FIPS was forced at startup; do not disable at runtime
if (!fipsEnabled && !process.execArgv.includes('--force-fips')) crypto.setFips(false); Defensive patterns
Strategy: try-catch
Validate before calling
const fipsForced = process.execArgv.some((a) => a.startsWith('--force-fips'));
if (!fipsForced) crypto.setFips(enabled); Try / catch
try { crypto.setFips(enabled); } catch (e) { if (e.code === 'ERR_CRYPTO_FIPS_FORCED') { /* FIPS is forced at startup; leave it on */ } else throw e; } Prevention
- Decide FIPS mode at process start only; remove runtime toggles.
- Check crypto.getFips() before any setFips() call.
When it happens
Trigger: 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').
Common situations: 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.
Related errors
- FIPS mode is not supported in Deno.
- Algorithm must be specified when using non-Ed25519 keys
- Can not create private key from
- can not create secret key from
- Context parameter is unsupported
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/9859151ad144f227.
Report an issue: GitHub.
Appendix: source
Thrown at ext/node/polyfills/crypto.ts:364
options?: TransformOptions,
) {
return Hmac_(hmac, key, options);
}
function createSign(algorithm: string, options?: WritableOptions): Sign {
return new Sign(algorithm, options);
}
function createVerify(algorithm: string, options?: WritableOptions): Verify {
return new Verify(algorithm, options);
}
function setFipsForced(val: boolean) {
if (val) {
return;
}
throw new ERR_CRYPTO_FIPS_FORCED();
}
function getFipsForced() {
return 1;
}
ObjectDefineProperty(constants, "defaultCipherList", {
__proto__: null,
value: getOptionValue("--tls-cipher-list"),
});
const getDiffieHellman = createDiffieHellmanGroup;
const getFips = fipsForced ? getFipsForced : getFipsCrypto;
const setFips = fipsForced ? setFipsForced : setFipsCrypto;
const sign = signOneShot;
const verify = verifyOneShot;View on GitHub (pinned to 9ad36f7a2c)