From c9c4d4ec6ad4aa7554cbfa90b2ff2932d3c9c65c Mon Sep 17 00:00:00 2001 From: Faseela K Date: Thu, 3 Dec 2026 14:09:16 +0100 Subject: [PATCH 1/5] Document PKIX path building failed error in truststore guide Closes #55785. Identified from the Keycloak community forum topic on this error, ahead of the forum's shutdown. Decisions and assumptions: - Added the troubleshooting note to the existing `keycloak-truststore.adoc` guide rather than a new standalone guide, since the cause and fix already live there. - Cross-referenced the database and outgoing-HTTP guides as the other places this error can surface, without duplicating their content. Drafted with AI assistance (GitHub Copilot), reviewed and verified by me. Signed-off-by: Faseela K --- docs/guides/server/keycloak-truststore.adoc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/guides/server/keycloak-truststore.adoc b/docs/guides/server/keycloak-truststore.adoc index ff582a75af9c..3869856293af 100644 --- a/docs/guides/server/keycloak-truststore.adoc +++ b/docs/guides/server/keycloak-truststore.adoc @@ -1,5 +1,6 @@ <#import "/templates/guide.adoc" as tmpl> <#import "/templates/kc.adoc" as kc> +<#import "/templates/links.adoc" as links> <@tmpl.guide title="Configuring trusted certificates" @@ -56,4 +57,17 @@ You may refine how hostnames are verified by TLS connections with the `tls-hostn + Please note that this setting does not apply to LDAP secure connections, which require strict hostname checking. +== Troubleshooting + +If {project_name}, or an application validating a token or certificate issued by {project_name}, reports an error such as: + +[source,text] +---- +PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target +---- + +the certificate being validated, or the certificate authority that issued it, is missing from the truststore used for that connection. This can happen for {project_name}'s own outgoing connections, for example to the database or to an external service (see <@links.server id="db"/> and <@links.server id="outgoinghttp"/>), or for an application that validates tokens or certificates issued by {project_name} itself. + +Add the missing certificate, or the certificate authority that signed it, to the truststore as described in <>. + From 6a392b9864476f734f22a609ec46e8505999b378 Mon Sep 17 00:00:00 2001 From: Faseela K Date: Thu, 3 Dec 2026 15:09:43 +0100 Subject: [PATCH 2/5] review comments Signed-off-by: Faseela K --- docs/guides/server/keycloak-truststore.adoc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/guides/server/keycloak-truststore.adoc b/docs/guides/server/keycloak-truststore.adoc index 3869856293af..5a06f9acf60f 100644 --- a/docs/guides/server/keycloak-truststore.adoc +++ b/docs/guides/server/keycloak-truststore.adoc @@ -59,15 +59,22 @@ Please note that this setting does not apply to LDAP secure connections, which r == Troubleshooting -If {project_name}, or an application validating a token or certificate issued by {project_name}, reports an error such as: +If a TLS connection involving {project_name} fails with an error such as: [source,text] ---- PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target ---- -the certificate being validated, or the certificate authority that issued it, is missing from the truststore used for that connection. This can happen for {project_name}'s own outgoing connections, for example to the database or to an external service (see <@links.server id="db"/> and <@links.server id="outgoinghttp"/>), or for an application that validates tokens or certificates issued by {project_name} itself. +the client side of that connection could not build a valid certificate chain from the server's certificate to a trusted certificate authority. Common causes are: -Add the missing certificate, or the certificate authority that signed it, to the truststore as described in <>. +* The server's certificate, or the certificate authority that issued it, is not in the truststore used by the client. +* The server does not send the intermediate certificates needed to complete the chain, even though the root certificate authority is trusted. Check the chain the server presents, for example with `openssl s_client -connect : -showcerts`, and fix the server configuration if intermediates are missing. + +Where to fix it depends on which side reports the error: + +* For outgoing connections from {project_name}, for example to an identity provider or another external service, add the certificate or certificate authority to the truststore as described in <>. See also <@links.server id="outgoinghttp"/>. +* For the database connection, if `db-tls-trust-store-file` is set, the driver validates against that file, so add the certificate there. Otherwise use the system truststore. See <@links.server id="db"/>. +* If an application connecting to {project_name} over HTTPS reports the error, for example when fetching the realm keys or calling the token endpoint, the application's own truststore is missing the {project_name} server certificate or its certificate authority. Update that application's truststore, not the {project_name} truststore. From ca5816df4cbc5f8c5e1083b0530b047c24be883b Mon Sep 17 00:00:00 2001 From: Faseela K Date: Thu, 3 Dec 2026 16:48:07 +0100 Subject: [PATCH 3/5] shorten the content Signed-off-by: Faseela K --- docs/guides/server/keycloak-truststore.adoc | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/docs/guides/server/keycloak-truststore.adoc b/docs/guides/server/keycloak-truststore.adoc index 5a06f9acf60f..f33d65d1863b 100644 --- a/docs/guides/server/keycloak-truststore.adoc +++ b/docs/guides/server/keycloak-truststore.adoc @@ -59,22 +59,19 @@ Please note that this setting does not apply to LDAP secure connections, which r == Troubleshooting -If a TLS connection involving {project_name} fails with an error such as: +If {project_name}, or an application connecting to it, logs the following error: [source,text] ---- PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target ---- -the client side of that connection could not build a valid certificate chain from the server's certificate to a trusted certificate authority. Common causes are: +the TLS client could not build a certificate chain from the server's certificate to a trusted certificate authority. Either the server's certificate or its certificate authority is missing from the client's truststore, or the server does not send its intermediate certificates. Check the chain with `openssl s_client -connect : -showcerts`. If intermediates are missing, fix the server configuration, or, if you do not control the server, add the intermediate certificate to the client's truststore. -* The server's certificate, or the certificate authority that issued it, is not in the truststore used by the client. -* The server does not send the intermediate certificates needed to complete the chain, even though the root certificate authority is trusted. Check the chain the server presents, for example with `openssl s_client -connect : -showcerts`, and fix the server configuration if intermediates are missing. +If the chain is complete, the certificate authority is not trusted by the truststore that the failing connection actually uses. Make sure the certificate is added to that truststore and that the truststore is loaded: -Where to fix it depends on which side reports the error: - -* For outgoing connections from {project_name}, for example to an identity provider or another external service, add the certificate or certificate authority to the truststore as described in <>. See also <@links.server id="outgoinghttp"/>. -* For the database connection, if `db-tls-trust-store-file` is set, the driver validates against that file, so add the certificate there. Otherwise use the system truststore. See <@links.server id="db"/>. -* If an application connecting to {project_name} over HTTPS reports the error, for example when fetching the realm keys or calling the token endpoint, the application's own truststore is missing the {project_name} server certificate or its certificate authority. Update that application's truststore, not the {project_name} truststore. +* {project_name} connecting to an external service, such as an identity provider: add the certificate or its certificate authority to the {project_name} truststore, as described in <>. See also <@links.server id="outgoinghttp"/>. +* {project_name} connecting to its database: update the trust source set by the `db-tls-*` options or by TLS properties in `db-url` or `db-url-properties`, otherwise usually the {project_name} truststore. See <@links.server id="db"/>. +* An application connecting to {project_name}: update the application's own truststore, not the {project_name} truststore. If TLS terminates at a proxy or ingress in front of {project_name}, that is the server whose certificate chain the application validates. From 029cfa18803ed8cd22f9b4d56458959d7f4de0ca Mon Sep 17 00:00:00 2001 From: Faseela K Date: Thu, 3 Dec 2026 17:05:02 +0100 Subject: [PATCH 4/5] Improve guidance on TLS certificate chain issues Clarified the reasons for TLS client certificate chain failures and updated instructions for ensuring the truststore is correctly configured. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Faseela K --- docs/guides/server/keycloak-truststore.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guides/server/keycloak-truststore.adoc b/docs/guides/server/keycloak-truststore.adoc index f33d65d1863b..4499e08f6891 100644 --- a/docs/guides/server/keycloak-truststore.adoc +++ b/docs/guides/server/keycloak-truststore.adoc @@ -66,9 +66,9 @@ If {project_name}, or an application connecting to it, logs the following error: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target ---- -the TLS client could not build a certificate chain from the server's certificate to a trusted certificate authority. Either the server's certificate or its certificate authority is missing from the client's truststore, or the server does not send its intermediate certificates. Check the chain with `openssl s_client -connect : -showcerts`. If intermediates are missing, fix the server configuration, or, if you do not control the server, add the intermediate certificate to the client's truststore. +the TLS client could not build a valid certificate chain from the server's certificate to a trusted certificate authority. Common causes include a missing trusted certificate authority or missing intermediate certificates. Check the chain with `openssl s_client -connect : -showcerts`. If intermediates are missing, fix the server configuration, or, if you do not control the server, add the intermediate certificate to the client's truststore. -If the chain is complete, the certificate authority is not trusted by the truststore that the failing connection actually uses. Make sure the certificate is added to that truststore and that the truststore is loaded: +If the chain is complete, also check certificate validity dates and the JVM's algorithm constraints. If the certificate authority is not trusted, make sure the appropriate certificate is added to the truststore that the failing connection actually uses and that the truststore is loaded: * {project_name} connecting to an external service, such as an identity provider: add the certificate or its certificate authority to the {project_name} truststore, as described in <>. See also <@links.server id="outgoinghttp"/>. * {project_name} connecting to its database: update the trust source set by the `db-tls-*` options or by TLS properties in `db-url` or `db-url-properties`, otherwise usually the {project_name} truststore. See <@links.server id="db"/>. From 71d8a8f3da8fefa5a7b78ea893f542dffdbbf2fd Mon Sep 17 00:00:00 2001 From: Faseela K Date: Thu, 3 Dec 2026 17:30:50 +0100 Subject: [PATCH 5/5] remove openssl reference to avoid confusion Signed-off-by: Faseela K --- docs/guides/server/keycloak-truststore.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/server/keycloak-truststore.adoc b/docs/guides/server/keycloak-truststore.adoc index 4499e08f6891..c94c7e35d5e0 100644 --- a/docs/guides/server/keycloak-truststore.adoc +++ b/docs/guides/server/keycloak-truststore.adoc @@ -66,7 +66,7 @@ If {project_name}, or an application connecting to it, logs the following error: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target ---- -the TLS client could not build a valid certificate chain from the server's certificate to a trusted certificate authority. Common causes include a missing trusted certificate authority or missing intermediate certificates. Check the chain with `openssl s_client -connect : -showcerts`. If intermediates are missing, fix the server configuration, or, if you do not control the server, add the intermediate certificate to the client's truststore. +the TLS client could not build a valid certificate chain from the server's certificate to a trusted certificate authority. Common causes include a missing trusted certificate authority or missing intermediate certificates. Check the certificate chain that the server presents, including any intermediate certificates. If intermediates are missing, fix the server configuration, or, if you do not control the server, add the intermediate certificate to the client's truststore. If the chain is complete, also check certificate validity dates and the JVM's algorithm constraints. If the certificate authority is not trusted, make sure the appropriate certificate is added to the truststore that the failing connection actually uses and that the truststore is loaded: