未能从加载URLhttps://example.com/auth/realms/REALM/.well-known/op



我使用带有keycloak的spring-boot服务进行登录。直到昨天,我在localhost:8081上有一个keycapture,但今天我们得到了一个新的Keycapture域(https://example.com)而不是仍然使用localhost:8081。为此,我不得不用新域更新我的"etc/hosts"文件。

问题是我无法从我的微服务启动任何请求。我有一个控制器,有很多端点,但我无法访问其中的任何一个,我得到了错误:

PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

带有此警告:

Failed to load URLs from https://example.com/auth/realms/REALM/.well-known/openid-configuration

但是,从Postman我可以访问以下URL:https://example.com/auth/realms/REALM/.well-known/openid-configuration

理论上,我已经用keycloak设置很好地配置了我的应用程序.yaml(我只需要更改auth路径,以前它是localhost,现在是我的https://example.com(

keycloak.auth-server-url: https://example.com/auth/
keycloak.realm: MyREALM
keycloak.resource: login
keycloak.public-client: true
keycloak.credentials.secret: mysecret

我访问了我的密钥斗篷(使用新域(,我试图导出证书,并使用Keytools将其集成到"cacerts"文件中,但我一直无法使其工作。

我试着阅读这些文章,但它们并不能解决我的问题:

Key斗篷:无法在Spring Boot应用程序中加载URL

"PKIX路径构建失败";以及";无法找到到请求目标的有效认证路径";

为什么我的微服务会给我这个错误?

2022-07-20 12:03:28.013 WARN 25996 --- [nio-8080-exec-4] o.keycloak.adapters.KeycloakDeployment : Failed to load URLs from https://example.com/auth/realms/MyREALM/.well-known/openid-configuration
javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131) ~[na:na]
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:370) ~[na:na]
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:313) ~[na:na]
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:308) ~[na:na]

我读了很多关于certificates的信息,下载了HTTPs网站的证书并将其添加到cacerts文件中,但它对我不起作用。

解决方案(暂时(是:

certificates的问题只出现在mi localhost中,而不出现在开发环境中。然后,在本地,我打开了一个与Keycloak服务的port-forward连接,后者抛出certificates-exception。它可以让我不直接从Spring Boot攻击域,避免证书错误。

port-forward service/keycloak 8081:8080

最新更新