jwtk/jjwt · error · WeakKeyException
The specified Elliptic Curve signing key is not strong enoug
Error message
The specified Elliptic Curve signing key is not strong enough to be used with JWT ECDSA signature algorithms. The JWT specification requires ECDSA keys to be >= 256 bits long. The specified ECDSA key is ${bitLength} bits. See https://tools.ietf.org/html/rfc7518#section-3.4 for more information. What it means
Error "The specified Elliptic Curve signing key is not strong enough to be used with JWT ECDSA signature algorithms. The JWT specification requires ECDSA keys to be >= 256 bits long. The specified ECDSA key is ${bitLength} bits. See https://tools.ietf.org/html/rfc7518#section-3.4 for more information." thrown in jwtk/jjwt.
Source
Thrown at api/src/main/java/io/jsonwebtoken/SignatureAlgorithm.java:650
// if we've made it this far in the method, the key is an ECKey due to the instanceof assertions at the
// top of the method
ECKey ecKey = (ECKey) key;
int bitLength = ecKey.getParams().getOrder().bitLength();
for (SignatureAlgorithm alg : PREFERRED_EC_ALGS) {
if (bitLength >= alg.minKeyLength) {
alg.assertValidSigningKey(key);
return alg;
}
}
String msg = "The specified Elliptic Curve signing key is not strong enough to be used with JWT ECDSA " +
"signature algorithms. The JWT specification requires ECDSA keys to be >= 256 bits long. " +
"The specified ECDSA key is " + bitLength + " bits. See " +
"https://tools.ietf.org/html/rfc7518#section-3.4 for more information.";
throw new WeakKeyException(msg);
}
/**
* Looks up and returns the corresponding {@code SignatureAlgorithm} enum instance based on a
* case-<em>insensitive</em> name comparison.
*
* @param value The case-insensitive name of the {@code SignatureAlgorithm} instance to return
* @return the corresponding {@code SignatureAlgorithm} enum instance based on a
* case-<em>insensitive</em> name comparison.
* @throws SignatureException if the specified value does not match any {@code SignatureAlgorithm}
* name.
*/
public static SignatureAlgorithm forName(String value) throws SignatureException {
for (SignatureAlgorithm alg : values()) {
if (alg.getValue().equalsIgnoreCase(value)) {
return alg;
}
}View on GitHub (pinned to fb71496164)
Solutions
- Generate a compliant EC key pair with Keys.keyPairFor(SignatureAlgorithm.ES256) or a larger curve (ES384/ES512) matching the desired algorithm.
- Use a curve whose order is >=256 bits (P-256 or larger); avoid small/odd curves like secp112/secp192.
- Match the ES* algorithm to the curve: >=256 bits allows ES256, >=384 ES384, >=512 ES512.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at api/src/main/java/io/jsonwebtoken/SignatureAlgorithm.java:650 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of jwtk/jjwt@fb71496164 (2026-09-09).
Data as JSON: /api/errors/30640e9b06f1b218.
Report an issue: GitHub.