我正在运行一个使用 oauth2.0 和 ssl 的本地 Spring Boot 应用程序。
我正在使用存储在 中的 zerossl 签名证书/src/main/resources
,并且我已经导入到项目资源中的钥匙串中。
我能够检索令牌并手动调用 /oauth/check_token 端点,但是当我尝试点击任何其他端点时,我收到以下错误:
.o.s.r.w.BearerTokenAuthenticationFilter : Authentication request for failed!
org.springframework.security.authentication.AuthenticationServiceException: I/O error on POST request for "https://localhost:8443/oauth/check_token": PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target;
nested exception is javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
application.properties
:
# The format used for the keystore. It could be set to JKS in case it is a JKS file
server.ssl.key-store-type=PKCS12
# The path to the keystore containing the certificate
server.ssl.key-store=classpath:demo.p12
# The password used to generate the certificate
server.ssl.key-store-password=*****
# The alias mapped to the certificate
server.ssl.key-alias=demo
server.ssl.enabled=true
security.oauth2.resource.token-info-uri=https://localhost:8443/oauth/check_token
security.oauth2.client.registered-redirect-uri=https://localhost:8443/test
spring.security.oauth2.resourceserver.opaquetoken.introspection-uri=https://localhost:8443/oauth/check_token
当 NimbusOpaqueTokenIntrospector 尝试通过调用POST https://localhost:8443/oauth/check_token
它来检查令牌时,单步执行代码甚至没有命中端点(我在 CheckTokenEndpoint 控制器中放置了一个断点)并得到上述 KPIX 错误。我尝试使用指定 SSL 上下文的自定义 RestTemplate,但我仍然看到相同的错误。