javax.net.ssl.SSLHandshakeException when Bamboo agent connects to server
0 reputation · 13 Apr 2021, 14:57 UTC
0 reputation · 13 Apr 2021, 14:57 UTC
When an Atlassian Bamboo agent attempts to establish an HTTPS connection to the Bamboo server, a self‑signed or expired certificate results in a javax.net.ssl.SSLHandshakeException. The agent logs the exception and fails to register, preventing build execution.
Agents are identified by hostname. Bamboo caches the resolved IP address for each agent. If the agent’s IP changes—e.g., due to a DNS update—the server continues to use the stale IP until the agent is re‑registered or the Bamboo server is restarted. This stale cache can cause the agent to appear offline or unable to reach the server.
All agents rely on the Java cacerts or a global trust store; there is no documented way to configure a custom trust store per agent. Consequently, any certificate that is not already trusted in the global store will trigger the same SSL handshake error across all agents.
1. What mechanisms can be employed to force Bamboo to refresh its DNS cache for registered agents without a full server restart?
2. Is there a supported approach to configure per‑agent trust stores or import custom certificates into individual agent instances?
3. Should Bamboo include automatic DNS refresh for agents whose IP addresses change, and if so, how would that be implemented?
35275 reputation · 13 Apr 2021, 19:35 UTC
To resolve a javax.net.ssl.SSLHandshakeException when a Bamboo agent connects to a server via HTTPS, you must ensure the Java Runtime Environment (JRE) used by the agent trusts the server's certificate. For self-signed or expired certificates, the agent's JVM will reject the connection during the TLS handshake, preventing registration.
This is the standard approach for agents sharing a common JRE. Import the server's public certificate into the default Java trust store:
keytool -importcert -alias bamboo-server -file server_cert.crt -keystore $JAVA_HOME/lib/security/cacerts
While Bamboo does not provide a UI setting for per-agent trust stores, you can isolate trust by passing JVM arguments to the agent process via JAVA_OPTS or the agent's startup script:
-Djavax.net.ssl.trustStore=/path/to/agent-truststore.jks-Djavax.net.ssl.trustStorePassword=changeitThe SSLHandshakeException occurs because the agent JVM cannot verify the server's identity. If the certificate is self-signed, it is not part of the default CA bundle. If it is expired, the JVM rejects it regardless of the signer. Using a custom trust store (Option 2) is safer than modifying the global cacerts, as it prevents updates to the JRE from overwriting your changes.
Bamboo servers cache the resolved IP addresses of registered agents. If an agent's IP changes due to a DNS update, the server may attempt to communicate with a stale IP, causing the agent to appear offline even if the SSL handshake is successful. Since there is no dedicated admin API to flush this specific cache, the most reliable remediation is to remove and re-add the agent via the Bamboo Administration UI to force a fresh resolution.
To verify the fix and diagnose the connection, use the following scoped commands on the agent host:
openssl s_client -connect <bamboo-host>:443 -servername <bamboo-host>keytool -list -v -keystore <path_to_truststore>atlassian-bamboo-agent.log for the full exception stack trace to confirm the handshake failure is resolved.Diagnostic Detail Needed: Are you using a shared JRE across multiple agents on a single host, or is each agent running in an isolated container/VM? This determines whether a global cacerts modification or a JAVA_OPTS override is the appropriate path.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.