【问题标题】:Getting "An error occurred while attempting to decode the Jwt: Couldn't retrieve remote JWK set: " error when trying to decode the jwt token尝试解码 Jwt 令牌时出现“尝试解码 Jwt 时发生错误:无法检索远程 JWK 集:”错误
【发布时间】:2021-12-12 18:00:28
【问题描述】:

这是我的资源服务器安全配置文件

    @Configuration
@EnableWebSecurity
public class SecureSecurityConfiguration extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .sessionManagement()
                .sessionCreationPolicy(STATELESS)
                .and()
                .authorizeRequests()
                .anyRequest()
                .permitAll()
                .antMatchers("api/**")
                .authenticated()
                .and()
                .oauth2ResourceServer()
                .jwt();
    }
}

这些是 Spring Boot 应用程序(资源服务器应用程序)的依赖项。

<dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-oauth2-core</artifactId>
        <version>5.5.3</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.security.oauth.boot</groupId>
        <artifactId>spring-security-oauth2-autoconfigure</artifactId>
        <version>2.1.6.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
    </dependency>

这是配置 yml 文件中的 jwk-set-url,我的应用程序在启动时连接到该文件

    spring:
  security:
    oauth2:
      resourceserver:
        jwt:
          jwk-set-uri: http://localhost:8083/.well-known/openid-configuration/jwks

现在通过邮递员,当我通过邮递员从身份验证服务器获取令牌并尝试向我的服务器请求时,我遇到了这种错误

Bearer error="invalid_token", error_description="An error occurred while attempting to decode the Jwt: Couldn't retrieve remote JWK set: org.springframework.web.client.HttpClientErrorException$NotFound: 404 null", error_uri="https://tools.ietf.org/html/rfc6750#section-3.1"

谁遇到过这样的问题?

【问题讨论】:

    标签: java spring oauth-2.0 jwt


    【解决方案1】:

    在 SSL 属性选项卡中将“主机名验证”更改为“无”。

    【讨论】:

    • 亲爱的 ujjwal dixit,请您详细介绍一下您所说的内容吗?你是说邮递员?
    猜你喜欢
    • 2020-02-20
    • 2021-10-22
    • 2020-12-20
    • 2020-05-07
    • 2016-11-08
    • 1970-01-01
    • 1970-01-01
    • 2021-12-20
    • 2021-06-30
    相关资源
    最近更新 更多