Skip to content
Advertisement

How can I get debug messages from Java’s SSL handshake?

I’m trying to secure a Java Spring Boot REST service with Keycloak. Part of that involves communication between the service and Keycloak to get the well-known OpenID configuration.

When everything is unencrypted (over HTTP), things work fine. When I add an SSL certificate into the mix (technically on an nginx server in front of both services), I’m getting an SSL handshake error.

If I hit the REST service or Keycloak directly with my browser, there’s no SSL error reported by the browser. Using curl from the rest server machine to the Keycloak machine looks fine as well, and I’ve tried having nginx force a TLS 1.2 or 1.3 response.

The error when the actual REST service tries to hit the Keycloak service looks like:

JavaScript

I’ve been looking through a lot of other answers such as this one, but I can’t seem to get the service to print any debug information beyond the actual exception. I’ve tried:

  • Adding -Djavax.net.debug=ssl to the command line that starts the server
  • Adding System.setProperty("javax.net.debug", "ssl"); to the main() function of the application
  • Adding logging.level.javax=TRACE and logging.level.net=TRACE to the application.properties

Nothing seems to get me anywhere. The output still just has the end of the server startup

JavaScript

followed by the error message

JavaScript

How do I get debugging enabled so I can figure out where the handshake is failing?

—- EDIT —-

Managed to get debug logging on – as comment below suggests, had to add the sub category, e.g.

JavaScript

That produces a ton of output, I’m not sure I see much of it being helpful:

JavaScript

Advertisement

Answer

The syntax to enable SSL debugging has apparently changed a little bit. This worked for me:

JavaScript

Full documentation here.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement