首页 > 解决方案 > 在 Keycloak 中配置身份联合时,无法进行身份提供者 oauth 回调

问题描述

Keycloak 托管在 Docker 容器内。目标是在 keyclaok(K1) 和另一个合作的 Keycloak (K2) 之间进行身份联合。K2 托管在 SSL 连接后面。

根据文档,我配置了信任库。但是,我仍然收到以下错误,

Exception: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
    at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1946)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:316)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:310)

我为此目的更新了standalone.xml

[1] - https://www.keycloak.org/docs/latest/server_installation/index.html#_truststore

标签: keycloak

解决方案


从 4.5.0 开始,Keycloak Docker 镜像默认使用standalone-ha.xml 而不是standalone.xml。这就是 Keycloak 无法识别新的信任库的原因。以下是使用基于 docker 的部署在 Keycloak 中配置信任库的步骤。

步骤1 :

将以下步骤添加到standalone-ha.xml 文件。

        <spi name="truststore">
            <provider name="file" enabled="true">
                    <properties>
                            <property name="file" value="/opt/jboss/truststore.jks"/>
                            <property name="password" value="password"/>
                            <property name="hostname-verification-policy" value="WILDCARD"/>
                            <property name="disabled" value="false"/>
                    </properties>
            </provider>
        </spi>

第2步:

将文件复制到 docker 容器

docker cp standalone-ha.xml continer_id:/opt/jboss/keycloak/standalone/configuration/standalone-ha.xml

第 3 步:

复制容器内的证书。证书可以从浏览器本身导出(公共证书)。

docker cp cert.crt 9fbd81264f65:/opt/jboss/cert.crt

第4步:

ssh 进入容器 docker exec -it container_id bash

第 5 步:

keytool -import -alias efactory-nimble.salzburgresearch.at -keystore truststore.jks -file cert.crt

第 6 步:

码头工人重新启动container_id

[1] - https://lists.jboss.org/pipermail/keycloak-user/2018-October/016066.html


推荐阅读