Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/353.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何修复SpringSecurityOAuth中不安全的jwt设置uri?_Java_Spring Boot_Jwk - Fatal编程技术网

Java 如何修复SpringSecurityOAuth中不安全的jwt设置uri?

Java 如何修复SpringSecurityOAuth中不安全的jwt设置uri?,java,spring-boot,jwk,Java,Spring Boot,Jwk,我使用keydepot作为授权服务器,使用spring引导应用程序作为资源服务器。KeyClope与自签名TLS一起工作。当我打开keydape jwk set uri时,它看起来如下所示: @Bean public JwtDecoder jwtDecoder(){ return NimbusJwtDecoder.withJwkStUri("https://192.168.1.4:8080/.../openid-connect/certs") } json格式的响应如下所示: {

我使用keydepot作为授权服务器,使用spring引导应用程序作为资源服务器。KeyClope与自签名TLS一起工作。当我打开keydape jwk set uri时,它看起来如下所示:

@Bean
public JwtDecoder jwtDecoder(){
   return NimbusJwtDecoder.withJwkStUri("https://192.168.1.4:8080/.../openid-connect/certs")
}

json格式的响应如下所示:

{
  "keys": [
    {
      "kid": "pI7XwYgG2l2ehgGg3XQ-N6Jc41_txjSzMQMWzLeyaiw",
      "kty": "RSA",
      "alg": "RS256",
      "use": "sig",
      "n": "nwGwgRywBMlKZreioz1nlo-PKWi...",
      "e": "AQAB",
      "x5c": [
        "MIICoTCCAYkCBgFte4jKkTANBgkqhki...jzxMCZL3Xkd4rs="
      ],
      "x5t": "CqljUhhfTCOMFMxORUXeotcSYxk",
      "x5t#S256": "4nlGCmpr6OYYHfkylCp2GGt9iefPRv_aq1DB..."
    }
  ]
}
JwtDecoder
bean定义如下:

@Bean
public JwtDecoder jwtDecoder(){
   return NimbusJwtDecoder.withJwkStUri("https://192.168.1.4:8080/.../openid-connect/certs")
}

当我使用
https
模式设置jwkSetUri时,应用程序不能正常工作,但如果我使用
http
模式设置它,应用程序就能正常工作。问题在哪里?如何修复它?

问题是,自签名TLS未在jvm中注册,因此它必须按如下方式注册:

@Bean
public JwtDecoder jwtDecoder(){
   return NimbusJwtDecoder.withJwkStUri("https://192.168.1.4:8080/.../openid-connect/certs")
}
  • 从浏览器导出cetificate
  • 使用
    keytool-Import-别名示例-keystore“C:\Program Files)\Java\jre1.6.0\u 22\lib\security\cacerts”-file certificate.cer或
    keytool-importcert-file certificate.cer-keystore“C:\Program Files)\Java\jre1.6.0\u 22\lib\security\cacerts”-别名示例。它将询问密码,jvm默认密码是
    changeit
  • 现在重新启动电脑,然后它将在安拉工作