Skip to content

Instantly share code, notes, and snippets.

@62mkv
Last active October 25, 2021 21:47
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save 62mkv/5811f70933692b0d51c79b3f40540cec to your computer and use it in GitHub Desktop.
How to debug SSL issues with Java-based server application

How to debug an HTTPS connection issue with Spring Boot based Java application

  1. Advanced logging:
  • java -jar -Djavax.net.debug=ssl:handshake:verbose app.jar
  1. make sure you specify correct configuration:
  • java -jar -Djavax.net.debug=ssl:handshake:verbose app.jar --server.port=8443 --server.security.require-ssl=true --server.ssl.key-store=/path/to/keystore --server.ssl.key-store-password=password --server.ssl.protocol=TLS
  1. See what’s in the store:
  • keytool -list -keystore /path/to/keystore -storepass password
Keystore type: PKCS12
Keystore provider: SUN

Your keystore contains 2 entries

hostname, Feb 1, 2018, PrivateKeyEntry,
Certificate fingerprint (SHA1): 47:FB:13:4E:48:91:76:1D:FE:06:15:4B:8B:EB:8E:21:02:AD:37:CA
caroot, Jul 16, 2019, trustedCertEntry,
Certificate fingerprint (SHA1): 1B:E0:B8:CE:E8:CB:B7:47:3D:8E:3A:63:9D:42:FA:04:D4:47:11:99
  1. Connect for remote debugging:
  • Start your app with java -jar -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y app.jar … parameters
  • Create an IntelliJ Run configuration to connect to the target: select “Remote” type of run configuration, and provide hostname and port (in this case 8000) in parameters
  • When an app is run, it should say “Listening to dt_socket on 8000” until you start debugging session for this configuration in IntelliJ IDEA
  1. Use proper JDK:
  • Sometimes line numbers, or even class/method names in some internal packages do not make any sense because of discrepancies between the JDK IDEA is configured for, and the one that’s used by the remote process.
  • To mitigate this, copy the whole JDK folder from the remote host (might be something like /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.201.b09-2.el7_6.x86_64) locally, create an empty Java project in IDEA and specify this folder as a “New” SDK when creating a project – in this case your debugging session, when run in this project, will display more correct information
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment