--- title: "Verify failed because all jwks size provided JWKs were filtered - 如何解决此 Elasticsearch 异常" date: 2026-02-16 lastmod: 2026-02-16 description: "Elasticsearch 异常解决方案" tags: ["Elasticsearch", "异常处理"] summary: "版本: 8.4-8.9 简而言之,当Elasticsearch的安全功能无法验证为JSON Web令牌(JWT)认证提供的JSON Web密钥集(JWKS)时,就会出现此错误。这可能是由于密钥不正确或不兼容造成的。要解决此问题,您可以:1)检查提供的JWKS是否存在任何错误或不一致。2)确保密钥与JWT认证兼容。3)如有必要,更新或重新生成密钥。4)检查过滤条件,因为它可能太严格,导致所有密钥都被过滤掉。 日志上下文 # 日志“Verify failed because all ” + jwks.size() + ” provided JWKs were filtered.”的类名是 JwtValidateUtil.java。 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入理解的人参考: final ListjwksStrength = jwksAlg.stream().filter(j -> JwkValidateUtil.isMatch(j; alg.getName())).toList(); LOGGER.debug("JWKs [{}] after Algorithm [{}] match filter."; jwksStrength.size(); alg); // No JWKs passed the kid; alg; and strength checks; so nothing left to use in verifying the JWT signature if (jwksStrength.isEmpty()) { throw new ElasticsearchException("Verify failed because all " + jwks." --- > **版本:** 8.4-8.9 简而言之,当Elasticsearch的安全功能无法验证为JSON Web令牌(JWT)认证提供的JSON Web密钥集(JWKS)时,就会出现此错误。这可能是由于密钥不正确或不兼容造成的。要解决此问题,您可以:1)检查提供的JWKS是否存在任何错误或不一致。2)确保密钥与JWT认证兼容。3)如有必要,更新或重新生成密钥。4)检查过滤条件,因为它可能太严格,导致所有密钥都被过滤掉。 日志上下文 ----------- 日志“Verify failed because all ” + jwks.size() + ” provided JWKs were filtered.”的类名是 [JwtValidateUtil.java。](https://www.geeksforgeeks.org/java-lang-class-class-java-set-1/) 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入理解的人参考: ```java final ListjwksStrength = jwksAlg.stream().filter(j -> JwkValidateUtil.isMatch(j; alg.getName())).toList(); LOGGER.debug("JWKs [{}] after Algorithm [{}] match filter."; jwksStrength.size(); alg); // No JWKs passed the kid; alg; and strength checks; so nothing left to use in verifying the JWT signature if (jwksStrength.isEmpty()) { throw new ElasticsearchException("Verify failed because all " + jwks.size() + " provided JWKs were filtered."); } for (final JWK jwk : jwksStrength) { if (jwt.verify(createJwsVerifier(jwk))) { LOGGER.trace( ```