Complete Solution for Db2 Encrypted Connection Setup:
Your TLS handshake failure is caused by three interconnected issues that need to be addressed together:
1. TLS Cipher Compatibility:
Db2 on Cloud supports a specific set of TLS 1.2 cipher suites. The IBM Data Server Driver requires explicit cipher suite configuration. The most reliable cipher suites for Java 11 compatibility are:
- `TLS_RSA_WITH_AES_128_CBC_SHA256
- `TLS_RSA_WITH_AES_256_CBC_SHA256
- `TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
2. Db2 SSL Configuration in JDBC:
Your connection string needs these properties:
jdbc:db2://hostname:50001/BLUDB:sslConnection=true;sslCipherSuite=TLS_RSA_WITH_AES_128_CBC_SHA256;sslTrustStoreLocation=/path/to/truststore.jks;sslTrustStorePassword=changeit;
3. Client Driver Support - Certificate Trust:
The SSL certificate must be imported into your Java truststore:
keytool -importcert -trustcacerts -file db2cert.crt \
-keystore /path/to/truststore.jks -storepass changeit -alias db2cloud
Complete Working Configuration:
Step 1: Download the SSL certificate from your Db2 service credentials (it’s in the certificate_base64 field).
Step 2: Create a dedicated truststore:
# Decode base64 certificate and save as db2cert.crt
echo "<certificate_base64>" | base64 -d > db2cert.crt
# Create new truststore
keytool -importcert -file db2cert.crt -alias db2cloud \
-keystore db2truststore.jks -storepass db2secure -noprompt
Step 3: Update JDBC connection with all required SSL properties:
String url = "jdbc:db2://dashdb-hostname:50001/BLUDB" +
":sslConnection=true" +
":sslCipherSuite=TLS_RSA_WITH_AES_128_CBC_SHA256" +
":sslTrustStoreLocation=/app/config/db2truststore.jks" +
":sslTrustStorePassword=db2secure";
Step 4: Verify your Java security policy allows TLS 1.2. Check java.security file and ensure TLSv1.2 is NOT in the jdk.tls.disabledAlgorithms list.
Troubleshooting Tips:
- Enable SSL debug logging: Add
-Djavax.net.debug=ssl:handshake to your Java options
- Verify certificate validity: `keytool -list -v -keystore db2truststore.jks
- Test with
openssl s_client -connect hostname:50001 -tls1_2 to confirm server cipher suites
Driver Version Note: Ensure you’re using IBM Data Server Driver v11.5.4 or later. Earlier versions have known TLS 1.2 compatibility issues with Db2 on Cloud.
After implementing all three components (cipher suite specification, certificate trust, and proper JDBC properties), your encrypted connections should work reliably. The key is that all three must be configured correctly - missing any one will cause handshake failures.