Overview
Following the answer of another Keycloak identity provider thread, I have two realms setup to keep users separate. The external realm contains a Keycloak OpenID Connect identity provider to the internal realm. Within the external realm there is a client configured which allows my application to validate users through a client adapter.
I am using Keycloak version 18.0.0.
Configuration
Any setting not specified is OFF, not set (blank entry), or the default.
The identity provider configured in the external realm has the following settings:
Enabled: trueStore Tokens: ONTrust Email: ONFirst Login Flow: first broker loginSync Mode: force- ODIC settings:
Auth URL,Token URL,Logout URL, andUser Info URLall set to the the matchinginternal realmclientClient Authentication: Client secret sent as basic authClient Secretset to matching client secretIssuerset tointernal realmURL. Ex:https://<hostname>/auth/realms/<internalRealmName>Default Scopes: openidPrompt: unspecifiedValidate Signatures: ON- Use
JWKS URL: ON,JWKS URLset to matchinginternal realmcert location. EX:https://<hostname>/auth/realms/<internalRealmName>/protocol/openid-connect/certs Use PKCE: ONPKCE Method: S256
The client configured in the internal realm has the following settings:
Enabled: trueClient Protocol: openid-connectAccess Type: confidentialStandard Flow Enabled: ONValid Redirect URIs: https://<hostname>/auth/realms/<externalRealmName>/broker/<internalRealmName>/endpointBackchannel Logout Session Required: ONCredentialsClient Authenticator: Client Id and Secret- Secret copied over and set in the
external realmidentity providerconfiguration
Problem
Users that exist in the external realm can login, as well as users that are configured to login through another separate external ODIC identity provider (This is not the identity provider to the internal realm, just an example that the identity provider login flow is working).
Users that attempt to login via the identity provider to the internal realm cannot login. The login page displays Unexpected error when authenticating with identity provider.
Checking the Keycloak logs, I see the following error:
WARN [org.keycloak.events] (default task-405) type=IDENTITY_PROVIDER_LOGIN_ERROR, realmId=<externalRealmName>, clientId=<externalRealmClientName>, userId=null, ipAddress=<removed>, error=identity_provider_login_failure, code_id=258c44bd-88fc-44a1-b93c-18225b00df49
ERROR [org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider] (default task-405) Failed to make identity provider oauth callback: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Request for help
Why would Keycloak be failing to validate the certificate when using this identity provider? It is able to authenticate successfully using the SSL setup for the external realm as well as another identity provider for an external connection. I can't figure out where the Keycloak certification failure is really happening.