在使用rsa非对称加密来实现spring security oauth2 整合jwt实现认证鉴权时出现Cannot convert access token to JSON
这是我的JwtAccessTokenConverter配置
@Bean
public JwtAccessTokenConverter jwtAccessTokenConverter() {
JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
//配置证书信息
KeyPair keyPair = new KeyStoreKeyFactory(
keyProperties.getKeyStore().getLocation(), //证书路径
keyProperties.getKeyStore().getSecret().toCharArray()) //证书秘钥
.getKeyPair(keyProperties.getKeyStore().getAlias(), //证书别名
keyProperties.getKeyStore().getPassword().toCharArray()); //证书密码
converter.setKeyPair(keyPair);
// String publicKey = new String(Base64.getEncoder().encode(keyPair.getPublic().getEncoded()));
converter.setVerifier(new RsaVerifier((RSAPublicKey) keyPair.getPublic()));
// converter.setVerifierKey(publicKey);
DefaultAccessTokenConverter accessTokenConverter = (DefaultAccessTokenConverter) converter.getAccessTokenConverter();
accessTokenConverter.setUserTokenConverter(customUserAuthenticationConverter);
return converter;
}
在测试check_token接口时出现Cannot convert access token to JSON
尝试设置Verifier后还是不能解析token