Debugging SSL issues in Java & tools to debug

Q1. What are some of the issues you encounter with SSL handshake?
A1. Some of the issues you try to debug are

  • Presence of a valid certificate in trust store
  • Incorrect certificate chains in the client or server truststore
  • Invalid key algorithm used for private keys
  • Expired certificate
  • Incorrect passwords used to access the keys
  • Multiple private keys to choose from

Q2. How does your SSL client look for the right certificate in a truststore?
A2. The client needs to have the truststore configured in any one of following ways and appropriate certificate imported into it.

Option 1: Specify it for a specific SSL connection via configuration files. For example, cxf.xml may look like

Example 1:

Example 2:

where you can define your “customSslHttpClientHttpRequestFactory” and supply the paths to keystore and trusstore locations.

Option 2: On the application server start up with a JVM argument

Option 3: When none of the above is specified, it defaults to your cacerts or jssecacerts

Q3. What are some of the tools you use to go about identifying and fixing SSL issues?
A3.

1. SSLPoke Java Utility

Step 1: Get the handy java file from the atlassian

Step 2: Run on a command line to test

2. OpenSSL

If you have cygwin running on your windows or working on a unix box, the openssl utility can be used to connect to an SSL-enabled service, and print each stage described above:

3. keytool to list all the certificates in the keystore

Check whether the keys are of a supported type, the required CA certificates are stored and that your application is using the correct one.

Check the “SHA1” or “SHA2” token to see if it matches with the certificate that you downloaded from a browser.

4. Turn on SSL handshake by turning on debug option

or

5. InstalCert Java class to install the certificates into “jssecacerts”


300+ Java Interview FAQs

Tutorials on Java & Big Data