Interview Prep/Real-World Interview/DNS, TLS and certificates

A Java service started failing calls to a partner API with "PKIX path building failed: unable to find valid certification path to requested target".

AdvancedTroubleshootingDNS, TLS and certificates
Answer

Likely causes → The partner rotated to a certificate from a CA that isn't in the JVM truststore you use: an old JDK cacerts, a custom truststore baked into the image with only the old CA, or a pinned certificate in code.

Diagnose →

openssl s_client -connect api.partner.com:443 -servername api.partner.com -showcerts </dev/null | grep 'i:'
keytool -list -cacerts -storepass changeit | grep -i "<new root name>"
java -Djavax.net.debug=ssl:handshake -jar app.jar 2>&1 | grep -i 'certificate_unknown'

Check whether the app passes -Djavax.net.ssl.trustStore= to a custom file.

Fix → Add the partner's new root to the truststore you actually use (keytool -importcert -alias partner-root -file root.pem -keystore truststore.jks), or move to the JDK's updated cacerts. Roll pods so the JVM reloads it.

Prevent → Avoid custom truststores that replace the default; append to it instead. Keep base JDK images current, and ask partners for CA-change notices.

All Real-World Interview questions Roadmap: Interview readiness

More on DNS, TLS and certificates