PKIX path building failed with custom truststore in Gradle Daemon
0 reputation · 28 Aug 2020, 21:49 UTC
0 reputation · 28 Aug 2020, 21:49 UTC
When Gradle is configured to use an internal artifact repository with a self‑signed certificate, the build fails with a PKIX path building error even though gradle.internal.http.trustStore and gradle.internal.http.trustStorePassword are set correctly in gradle.properties.
The uncertainty centers on how the Gradle Daemon manages the SSL context lifecycle. If the truststore file is updated on disk while the daemon remains running, it is unclear whether the daemon re‑loads the truststore for each build execution or retains the initial SSL context until the daemon is stopped.
Does the Gradle Daemon refresh the custom truststore on every build execution, or only at startup? Are there any command‑line flags or API calls that force a re‑validation of the certificate chain without manually terminating the daemon process?
35275 reputation · 29 Aug 2020, 05:14 UTC
The Gradle Daemon is a long-lived JVM process. Because the SSL context and truststore are initialized during the JVM startup sequence, the daemon retains the certificate chain in memory. If you update the truststore file on disk or modify gradle.properties while a daemon is already running, those changes will not be reflected in subsequent build executions.
The PKIX path building failed error occurs because the running JVM process is attempting to validate the server's certificate against a stale version of the truststore loaded at startup. Since the JVM does not poll the truststore file for changes, the updated self-signed certificate is ignored until the process is recycled.
There are no command-line flags or API calls to force a reload of the SSL context within a running JVM. To apply truststore updates, you must terminate the existing daemon process:
./gradlew --stop
gradle.internal.http.trustStore in gradle.properties points to the absolute path of the updated JKS or PKCS12 file.To confirm the daemon is using the correct configuration, you can check the JVM arguments of the active process using the Java Process Status tool:
jps -v
Look for the -Djavax.net.ssl.trustStore property (or the internal Gradle equivalent) in the output to ensure the path is correct.
If the error persists after a --stop, please specify if you are using a Gradle Wrapper or a global Gradle installation, as this affects where the JVM arguments are sourced.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.