title: Curl Request to https endoint working but java client request fails with Error 'javax.net.ssl.SSLHandshakeException'
body: <p>I am trying to connect to an https endpoint by making GET request with java client. the endpoint is like this '<a href="https://domain/path/" rel="nofollow noreferrer">https://domain/path/</a>{token}',but every time i make a reqeust i get   <em>'javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure'</em>  Exception    ,  i scoured a lot of websites but no luck. Interestingly when i make the same request via POSTMAN from a different host (windows) it works,also i copied the  curl command   generated from POSTMAN and ran  on the HOST where my client is running it works fine there too. only the java code is not able to connect to the endpoint.
  Now my questions are :<br>
  --->is this a certificate issue.<br>
  --->if so ,how does curl works without needing the certificate.  </p>
  
  <p>Thanks.</p>
  
  <p>NOTE:Following are the things already tried:<br>
  -->set the same set of HEADERS present with curl command for the java client connection .<br>
  -->also used alternative rest clients (okhttp3) and HttpClient libraries but get the same exception.</p>
  
  <p>Please find the  working curl command below:</p>
  
  <pre class="lang-sh prettyprint-override"><code>curl -X GET \
    https://domain/x/y/XUwDummyTokenRKZ80EnxDCJlM \
    -H 'Accept: */*' \
    -H 'Cache-Control: no-cache' \
    -H 'Connection: keep-alive' \
    -H 'Host:hostname' \
    -H 'accept-encoding: gzip, deflate' \
    -H 'cache-control: no-cache
  </code></pre>
  
  <p>also the java client code being used to connect to the https endpoint:</p>
  
  <pre class="lang-java prettyprint-override"><code> public void printGetResult( String destUrlStr ) {
          try {
             URL url = new URL(destUrlStr);
             HttpsURLConnection conn = (HttpsURLConnection)url.openConnection();
             conn.setRequestMethod( "GET" );
  
             InputStream is = conn.getInputStream();
             InputStreamReader isr = new InputStreamReader(is);
             BufferedReader br = new BufferedReader(isr);
  
             String inputLine;
  
             while ((inputLine = br.readLine()) != null) {
                 System.out.println(inputLine);
             }
  
             br.close();
  
  
       }catch(Exception e) {
          System.out.println("exception is"+e); 
       }
  
      }
  </code></pre>
  
  <p>Expected result: json<br>
  (i know in my curl request i have set accept as * ,but it works)<br>
  Actual Result:  </p>
  
  <p>javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure</p>