Java 部署的应用程序无法将oauth2代码交换为令牌
在当地一切正常 然而,在raspberrypi上部署到我的Kubernetes k3s集群(可通过https域访问)后,oauth2代码交换令牌功能不起作用。我目前支持通过Google和GitHub进行身份验证,这两个网站都有这个问题。以下是日志: GitHub登录失败:Java 部署的应用程序无法将oauth2代码交换为令牌,java,spring,kubernetes,spring-security-oauth2,Java,Spring,Kubernetes,Spring Security Oauth2,在当地一切正常 然而,在raspberrypi上部署到我的Kubernetes k3s集群(可通过https域访问)后,oauth2代码交换令牌功能不起作用。我目前支持通过Google和GitHub进行身份验证,这两个网站都有这个问题。以下是日志: GitHub登录失败: org.springframework.security.oauth2.core.OAuth2AuthenticationException: [invalid_token_response] An error occurr
org.springframework.security.oauth2.core.OAuth2AuthenticationException:
[invalid_token_response] An error occurred while attempting to retrieve the OAuth 2.0 Access Token Response: Error while extracting response for type [class org.springframework.security.oauth2.core.endpoint.OAuth2AccessTokenResponse] and content type [application/json;charset=utf-8];
nested exception is org.springframework.http.converter.HttpMessageNotReadableException: An error occurred reading the OAuth 2.0 Access Token Response: tokenValue cannot be empty;
nested exception is java.lang.IllegalArgumentException: tokenValue cannot be empty
org.springframework.security.oauth2.core.OAuth2AuthenticationException:
[invalid_token_response] An error occurred while attempting to retrieve the OAuth 2.0 Access Token Response: I/O error on POST request for "https://www.googleapis.com/oauth2/v4/token": Invalid ECDH ServerKeyExchange signature;
nested exception is javax.net.ssl.SSLHandshakeException: Invalid ECDH ServerKeyExchange signature
谷歌登录失败:
org.springframework.security.oauth2.core.OAuth2AuthenticationException:
[invalid_token_response] An error occurred while attempting to retrieve the OAuth 2.0 Access Token Response: Error while extracting response for type [class org.springframework.security.oauth2.core.endpoint.OAuth2AccessTokenResponse] and content type [application/json;charset=utf-8];
nested exception is org.springframework.http.converter.HttpMessageNotReadableException: An error occurred reading the OAuth 2.0 Access Token Response: tokenValue cannot be empty;
nested exception is java.lang.IllegalArgumentException: tokenValue cannot be empty
org.springframework.security.oauth2.core.OAuth2AuthenticationException:
[invalid_token_response] An error occurred while attempting to retrieve the OAuth 2.0 Access Token Response: I/O error on POST request for "https://www.googleapis.com/oauth2/v4/token": Invalid ECDH ServerKeyExchange signature;
nested exception is javax.net.ssl.SSLHandshakeException: Invalid ECDH ServerKeyExchange signature
我已经尝试过的:
我认为从Kubernetes集群中发送https请求可能会有问题,但我连接到运行的pod并进行了卷曲,它工作得很好
你们有没有遇到过这样的问题
@编辑
我正在使用Java11
@编辑2
我的raaspberrypi上的docker似乎有问题。卷曲https请求工作正常,但在Java中使用restemplate
不起作用
@编辑3
发现相关问题假设您在本地和Kubernetes使用完全相同的容器/可执行文件/库,并且根据您共享的错误消息,最可能的原因是本地环境和Kubernetes环境之间的凭据和/或私钥不同 不过,Github和Google的错误看起来有所不同。第一个错误(GitHub)似乎是您发送了一个空令牌 第二个错误(Google)似乎是您发送的私钥与证书不匹配。基于:
无效的ECDH ServerKeyExchange签名可以指示密钥
和相应的证书不匹配,导致
握手失败。验证您正在创建的每个文件的内容
用于配置的证书颁发机构、证书和
钥匙。特别是,检查密钥和证书是否属于
相同的密钥对
问题已解决,并且根本不与spring或oauth配置连接
arm的OpenJDK Docker映像已损坏。它阻止进行https请求。甚至以下示例也失败了:
RestTemplate().getForEntity(“https://google.com,字符串::class.java)
因此,解决方案是在Dockerfile中交换断开的基本映像,如下所示:
以前的:
FROM adoptopenjdk/openjdk11:armv7l-ubuntu-jdk-11.0.6_10-slim
当前:
FROM arm32v7/openjdk:11.0.3-slim
是的,关于证书你是对的。我在Github把他们搞砸了。