Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.
 

HTTPS/HTTP SSL Handshake Exception while using TestRail Java API


#1

Hi there,

I am trying to use TestRail Java API for my project. Whenever I am trying to access/make HTTP request to my TestRail URL (something like https://sv5-testrail-1.nd.some.com/testrail/, my implementation is throwing

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed:

Am I missing something? I have checked with the TestRail server guy and the server on which TestRail is deployed does support HTTPS(since that is recommended one). Is there anything missing as a part of certificate? Also, it does not seem to work for HTTP.

Here is the detailed log:

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1904) at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:279) at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:273) at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1446) at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:209) at sun.security.ssl.Handshaker.processLoop(Handshaker.java:901) at sun.security.ssl.Handshaker.process_record(Handshaker.java:837) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1023) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1359) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1343) at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1301) at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338) at com.qa.mobile.common.utils.testrail.client.APIClient.sendRequest(APIClient.java:155) at com.qa.mobile.common.utils.testrail.client.APIClient.sendGet(APIClient.java:93)

The line at which the code fails is:

JSONArray arr = (JSONArray) client.sendGet(uri.GET_PROJECTS.toString());

Thoughts and solutions would be appreciated.


#2

Hi Pratik,

Thanks for your posting. That’s a Java configuration issue and this is independent of TestRail. It seems that your Java installation has an incorrect SSL/certificate setup and I found the following references which should help with this:

http://stackoverflow.com/questions/18378869/pkix-path-building-failed-in-java-application
http://stackoverflow.com/questions/21076179/pkix-path-building-failed-and-unable-to-find-valid-certification-path-to-requ

I hope this helps!

Cheers,
Tobias


#3

Hi Tobias,

Excellent support. I figured out yesterday that it was an issue with my certificate.

Thanks for sending the links though (they address my question).

Pratik


#4

Hello Pratik,

Great to hear that this helped :slight_smile:

Cheers,
Tobias