Crypto operation is not supported
Production Risk
Can cause auth or encryption to fail on non-standard deployments; test against the target environment.
Thrown when a requested cryptographic operation is not supported by the current Node.js build or the underlying OpenSSL version. This can happen when using algorithms or key types that are disabled in the OpenSSL build, or when attempting operations not valid for the key type.
- 1Using an algorithm not available in the current OpenSSL build
- 2Requesting an operation that is not supported by the key type
- 3FIPS mode enabled and the requested algorithm is not FIPS-compliant
Triggered when the crypto subsystem cannot perform the requested operation.
const { createSign } = require('crypto');
// Ed448 may not be available in all builds
const sign = createSign('ed448');
sign.update('data');
sign.sign(key); // may throw if ed448 not supportedexpected output
Error [ERR_CRYPTO_UNSUPPORTED_OPERATION]: Operation not supported
Fix 1
Use a widely supported algorithm
WHEN When targeting broad compatibility
// Use Ed25519 instead of Ed448 for broad support
const { generateKeyPairSync, createSign } = require('crypto');
const { privateKey } = generateKeyPairSync('ed25519');
const sign = createSign('SHA256');
sign.update('data');
const signature = sign.sign(privateKey);Why this works
Widely supported algorithms like Ed25519, RSA, and AES are available in all standard builds.
Fix 2
Check crypto.getCiphers() / getHashes() before using an algorithm
WHEN When using optional or rare algorithms
const { getHashes } = require('crypto');
if (getHashes().includes('sha3-256')) {
// safe to use
}Why this works
Checking availability at runtime avoids errors on builds where the algorithm is absent.
const { createSign } = require('crypto');
// Ed448 may not be available in all builds
const sign = createSign('ed448');
sign.update('data');
sign.sign(key); // may throw if ed448 not supported // this triggers ERR_CRYPTO_UNSUPPORTED_OPERATIONtry {
// operation that may throw ERR_CRYPTO_UNSUPPORTED_OPERATION
riskyOperation()
} catch (err) {
if (err.code === 'ERR_CRYPTO_UNSUPPORTED_OPERATION') {
console.error('ERR_CRYPTO_UNSUPPORTED_OPERATION:', err.message)
} else {
throw err
}
}// Validate inputs before calling the operation
function safe_err_crypto_unsupported_operation(...args) {
// validate args here
return performOperation(...args)
}✕ Assume all crypto algorithms are available on all platforms
OpenSSL builds vary; FIPS mode and platform builds exclude many algorithms.
Node.js Error Codes Documentation
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev