Skip to content
Advertisement

How connection with JIRA using RESTAPI with java?

My task is to establish a connection to JIRA in java using RESTAPI. I’m facing an error with the SSL security certificate. I have tried many times and looked on google, but I didn’t find any solution to my problem. Can anyone help me to fix this error?

APOD.java

JavaScript

JavaHttpURLConnectionDemo.java

JavaScript

Error

JavaScript

Advertisement

Answer

HttpsURLConnection is using by default the JDK trusted certificates to validate the server certificate whether it is known and trusted. If it is present over there it won’t throw a SSLHandshakeException

Jira has currently the following certificate chain:

Jira server certificate

You can easily verify whether your HttpsURLConnection has the trusted certificate by adding a breakpoint after initializing the HttpsURLConnection See below for an example:

debug information

So my assumption is that in your case the certificate is not present in the JDK truststore. What you can do is extract the Jira certificate, just like shown here: Using openssl to get the certificate from a server afterwords either import it into cacert file here: $JAVA_HOME/lib/security/cacerts. But I think it will be better to provide a custom ssl configuration to your HttpsUrlConnection as it would be more maintainable in my opinion. But either options will work.

So the following code snippet is for option 2 when using custom trustore:

Option 2

JavaScript

Or you can do everything inline without the custom truststore from your filesystem as shown below. In this way you have the the root ca as pem, which is DigiCert High Assurance EV ROOT CA and load it programatically into your in memory truststore.

Option 3

JavaScript

Last resort would be disable the certificate validation, but I would not recommend that. Below is an example for that:

Option 4

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