环境
- EMQX 版本:5.0.24
- 操作系统版本:centos 7
重现此问题的步骤
- java写了一个返回jwks的接口,格式如图中返回的json一样
- 通过上诉的jwks生成了jwt,代码如下图
@GetMapping("/jwt")
public R getJwksJwt() throws JOSEException, IOException, ParseException {
// JWKS endpoint URL or JWKS JSON
URL jwksURL = new URL("http://127.0.0.1:8000");
// Parse the JWKS
JWKSet jwkSet = JWKSet.load(jwksURL);
// Select a JWK from the JWKS
RSAKey rsaKey = (RSAKey)jwkSet.getKeyByKeyId("my-key-id");
// Extract the private key from the JWK (assuming it's an RSA key)
RSAPrivateKey privateKey = redisService.getCacheObject("rsaPrivateKey");
// Create a JWT signer with the private key
JWSSigner signer = new RSASSASigner(privateKey);
// Create a JWT header
JWSHeader header = new JWSHeader.Builder(JWSAlgorithm.RS256)
.keyID(rsaKey.getKeyID())
.build();
// Create a JWT payload
JWTClaimsSet claimsSet = new JWTClaimsSet.Builder()
.build();
// Create a signed JWT
SignedJWT signedJWT = new SignedJWT(header, claimsSet);
// Sign the JWT
signedJWT.sign(signer);
// Serialize the JWT to its final string representation
String jwtString = signedJWT.serialize();
return R.ok().setCode(200).data("jwt",jwtString);
}
- 显示无法登录
预期行为
通过我配置的jwks可进行登录认证
实际行为
认证失败


