jwtk/jjwt · error · UnsupportedKeyException

Unrecognized OKP JWK ${param} value '${crvId}'

Error message

Unrecognized OKP JWK ${param} value '${crvId}'

What it means

When converting an OKP (Octet Key Pair) JWK, the 'crv' parameter must identify a supported Edwards curve (Ed25519 or Ed448). If EdwardsCurve.findById(crvId) returns null for the given value, an UnsupportedKeyException is thrown.

Source

Thrown at impl/src/main/java/io/jsonwebtoken/impl/security/OctetJwkFactory.java:43

public abstract class OctetJwkFactory<K extends Key, J extends Jwk<K>> extends AbstractFamilyJwkFactory<K, J> {

    OctetJwkFactory(Class<K> keyType, Set<Parameter<?>> params) {
        super(DefaultOctetPublicJwk.TYPE_VALUE, keyType, params);
    }

    @Override
    public boolean supports(Key key) {
        return super.supports(key) && EdwardsCurve.isEdwards(key);
    }

    protected static EdwardsCurve getCurve(final ParameterReadable reader) throws UnsupportedKeyException {
        Parameter<String> param = DefaultOctetPublicJwk.CRV;
        String crvId = reader.get(param);
        EdwardsCurve curve = EdwardsCurve.findById(crvId);
        if (curve == null) {
            String msg = "Unrecognized OKP JWK " + param + " value '" + crvId + "'";
            throw new UnsupportedKeyException(msg);
        }
        return curve;
    }
}

View on GitHub (pinned to fb71496164)

Solutions

  1. Set crv exactly to a supported value: 'Ed25519' or 'Ed448' (case-sensitive).
  2. Upgrade JJWT to a version that supports the desired Edwards curve.
  3. Wrap JWK parsing in try-catch for UnsupportedKeyException to handle foreign keys gracefully.

Example fix

// before
{"kty":"OKP","crv":"ed25519","x":"..."}
// after
{"kty":"OKP","crv":"Ed25519","x":"..."}
Defensive patterns

Strategy: validation

Validate before calling

String crv = jwk.get("crv", String.class);
if (!"Ed25519".equals(crv) && !"Ed448".equals(crv)) {
    throw new UnsupportedKeyException("Unsupported OKP crv: " + crv);
}

Try / catch

try {
    Jwk jwk = Jwks.parser().build().parse(json);
} catch (UnsupportedKeyException e) {
    // unknown/unsupported crv
}

Prevention

When it happens

Trigger: Parsing or building an OKP JWK whose 'crv' value is null, misspelled, or an unsupported curve name (anything other than 'Ed25519' or 'Ed448').

Common situations: Copy-pasted JWKs from other implementations with case mismatches ('ed25519' vs 'Ed25519'), typos in the crv field, or JWKs from curves this JJWT version does not support.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of jwtk/jjwt@fb71496164 (2026-09-09). Data as JSON: /api/errors/87ae7752280ab37f. Report an issue: GitHub.