【发布时间】:2017-01-30 00:44:22
【问题描述】:
我从 OAuth 服务器收到 jwt(访问令牌)。 OAuth 服务器已经为我提供了密钥、公钥和自签名 CA 证书。
我想编写一个代码,当我收到 jwt 时,我可以验证它并检查此服务器是否已将它发送给我。我使用以下代码在 java 中验证我的 jwt。
String jwt = "xxx.yyy.zzz";
//This line will throw an exception if it is not a signed JWS (as expected)
Claims claims = Jwts.parser().setSigningKey(DatatypeConverter.parseBase64Binary(self_signed_CA_Certificate))
.parseClaimsJws(jwt).getBody();
我收到错误:Key bytes cannot be specified for RSA signatures. Please specify a PublicKey or PrivateKey instance.
感谢任何帮助。
【问题讨论】: