已部署的应用程序无法将 oauth2 代码交换为令牌
Deployed app cannot exchange oauth2 code for token
本地一切正常!
但是,在 raspberrypi 上部署到我的 Kubernetes k3s 集群后,可通过 https 域访问,oauth2 代码交换令牌功能不起作用。我目前支持通过 Google 和 GitHub 进行身份验证,它们都有这个问题。以下是日志:
GitHub登录失败:
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
Google登录失败:
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 并卷曲 https://google.com,它工作得很好。
大家遇到过这样的问题吗?
@编辑
我正在使用 Java 11
@edit2
我的 raaspberrypi 上的 docker 似乎有问题。卷曲 https 请求工作正常,但在 Java 中使用 RestTemplate
不起作用
@edit3
发现一个相关问题 https://github.com/docker-library/tomcat/issues/182
假设您在本地和 Kubernetes 使用完全相同的 container/executable/libraries 并且根据您共享的错误消息,最可能的原因是您的本地环境和 Kubernetes 之间的凭据不同 and/or 私钥您的 Kubernetes 环境。
Github 和 Google 的错误看起来不同。第一个错误 (GitHub) 似乎您正在发送一个空令牌。
第二个错误 (Google) 似乎您发送的私钥与证书不匹配。基于 on similar Java errors:
The Invalid ECDH ServerKeyExchange signature
can indicate that a key
and a corresponding certificate don’t match and are causing the
handshake to fail. Verify the contents of each of the files you are
using for your configured certificate authorities, certificates and
keys. In particular, check that the key and certificate belong to the
same key pair.
问题已解决并且根本没有与 spring 或 oauth 配置相关联。
Adoptopenjdk Docker 手臂图像已损坏。它会阻止发出 https 请求。即使是下面的例子也失败了:
RestTemplate().getForEntity("https://google.com", String::class.java)
所以解决方案是像这样在我的 Docker 文件中交换损坏的基本图像:
上一个:
FROM adoptopenjdk/openjdk11:armv7l-ubuntu-jdk-11.0.6_10-slim
当前:
FROM arm32v7/openjdk:11.0.3-slim
本地一切正常!
但是,在 raspberrypi 上部署到我的 Kubernetes k3s 集群后,可通过 https 域访问,oauth2 代码交换令牌功能不起作用。我目前支持通过 Google 和 GitHub 进行身份验证,它们都有这个问题。以下是日志:
GitHub登录失败:
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
Google登录失败:
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 并卷曲 https://google.com,它工作得很好。
大家遇到过这样的问题吗?
@编辑 我正在使用 Java 11
@edit2
我的 raaspberrypi 上的 docker 似乎有问题。卷曲 https 请求工作正常,但在 Java 中使用 RestTemplate
不起作用
@edit3 发现一个相关问题 https://github.com/docker-library/tomcat/issues/182
假设您在本地和 Kubernetes 使用完全相同的 container/executable/libraries 并且根据您共享的错误消息,最可能的原因是您的本地环境和 Kubernetes 之间的凭据不同 and/or 私钥您的 Kubernetes 环境。
Github 和 Google 的错误看起来不同。第一个错误 (GitHub) 似乎您正在发送一个空令牌。
第二个错误 (Google) 似乎您发送的私钥与证书不匹配。基于 on similar Java errors:
The
Invalid ECDH ServerKeyExchange signature
can indicate that a key and a corresponding certificate don’t match and are causing the handshake to fail. Verify the contents of each of the files you are using for your configured certificate authorities, certificates and keys. In particular, check that the key and certificate belong to the same key pair.
问题已解决并且根本没有与 spring 或 oauth 配置相关联。
Adoptopenjdk Docker 手臂图像已损坏。它会阻止发出 https 请求。即使是下面的例子也失败了:
RestTemplate().getForEntity("https://google.com", String::class.java)
所以解决方案是像这样在我的 Docker 文件中交换损坏的基本图像:
上一个:
FROM adoptopenjdk/openjdk11:armv7l-ubuntu-jdk-11.0.6_10-slim
当前:
FROM arm32v7/openjdk:11.0.3-slim