ERR_CRYPTO_UNSUPPORTED_OPERATION
Node.jsERRORNotableCryptoHIGH confidence

Crypto operation is not supported

Production Risk

Can cause auth or encryption to fail on non-standard deployments; test against the target environment.

What this means

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.

Why it happens
  1. 1Using an algorithm not available in the current OpenSSL build
  2. 2Requesting an operation that is not supported by the key type
  3. 3FIPS mode enabled and the requested algorithm is not FIPS-compliant
How to reproduce

Triggered when the crypto subsystem cannot perform the requested operation.

trigger — this will error
trigger — this will error
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

expected output

Error [ERR_CRYPTO_UNSUPPORTED_OPERATION]: Operation not supported

Fix 1

Use a widely supported algorithm

WHEN When targeting broad compatibility

Use a widely supported algorithm
// 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

Check crypto.getCiphers() / getHashes() before using an algorithm
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.

Code examples
Triggerjs
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_OPERATION
Handle in try/catchjs
try {
  // 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
  }
}
Defensive pattern to avoid itjs
// Validate inputs before calling the operation
function safe_err_crypto_unsupported_operation(...args) {
  // validate args here
  return performOperation(...args)
}
What not to do

Assume all crypto algorithms are available on all platforms

OpenSSL builds vary; FIPS mode and platform builds exclude many algorithms.

Same error in other languages
Sources
Official documentation ↗

Node.js Error Codes Documentation

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All Node.js errors