{"record":{"id":"69ea8ddba5b15f69","repo":"keycloak/keycloak","slug":"fail-to-retrieve-ecpublicjwk-crv-ecpublicjwk-x-or","errorCode":null,"errorMessage":"Fail to retrieve ECPublicJWK.CRV, ECPublicJWK.X or ECPublicJWK.Y field.","messagePattern":"Fail to retrieve ECPublicJWK\\.CRV, ECPublicJWK\\.X or ECPublicJWK\\.Y field\\.","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/keycloak/jose/jwk/JWKParser.java","lineNumber":101,"sourceCode":"            return JWKBuilder.EdEC_UTILS.createOKPPublicKey(jwk);\n        } else if (KeyType.AKP.equals(keyType)) {\n            return createAPKPublicKey(normalizedJwk);\n        } else {\n            throw new RuntimeException(\"Unsupported keyType \" + keyType);\n        }\n    }\n\n    private static PublicKey createECPublicKey(RawJsonValue jwk) {\n\n\n        /* Try retrieving the necessary fields */\n        String crv = jwk.path(ECPublicJWK.CRV).asText(null);\n        String xStr = jwk.get(ECPublicJWK.X).asText(null);\n        String yStr = jwk.get(ECPublicJWK.Y).asText(null);\n\n        /* Check if the retrieving of necessary fields success */\n        if (crv == null || xStr == null || yStr == null) {\n            throw new RuntimeException(\"Fail to retrieve ECPublicJWK.CRV, ECPublicJWK.X or ECPublicJWK.Y field.\");\n        }\n\n        BigInteger x = new BigInteger(1, Base64Url.decode(xStr));\n        BigInteger y = new BigInteger(1, Base64Url.decode(yStr));\n\n        String name;\n        switch (crv) {\n            case \"P-256\" :\n                name = \"secp256r1\";\n                break;\n            case \"P-384\" :\n                name = \"secp384r1\";\n                break;\n            case \"P-521\" :\n                name = \"secp521r1\";\n                break;\n            default :\n                throw new RuntimeException(\"Unsupported curve\");","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/keycloak/keycloak/blob/66c7e15a3788de7764f07dd2558275a02770e16d/core/src/main/java/org/keycloak/jose/jwk/JWKParser.java#L83-L119","documentation":"Error \"Fail to retrieve ECPublicJWK.CRV, ECPublicJWK.X or ECPublicJWK.Y field.\" thrown in keycloak/keycloak.","triggerScenarios":"Parsing an EC JWK that is missing the crv, x, or y fields required to reconstruct the public key.","commonSituations":"Occurs with hand-crafted or truncated EC JWK documents, or JWKS responses that omit coordinate fields.","solutions":["Ensure the EC JWK contains all three required fields: 'crv', 'x', and 'y'.","Verify the JWK JSON is complete and not truncated; 'x' and 'y' must be Base64URL-encoded coordinates.","Re-export the EC public key as a proper JWK using a library such as Nimbus JOSE JWT or Keycloak's JWKBuilder."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"66c7e15a3788de7764f07dd2558275a02770e16d","analyzedAt":"2026-08-14T01:36:42.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}