title: javax.net.ssl.SSLHandshakeException while connecting to an okta server
body: <p>I'm following the steps for autherisation of okta server with the below link.
  [<a href="https://developer.okta.com/authentication-guide/implementing-authentication/auth-code][1]" rel="nofollow noreferrer">https://developer.okta.com/authentication-guide/implementing-authentication/auth-code][1]</a>
  In the second step we have a get request to get the code from okta. I'm using jersey webservice with jboss server. I have the following code for getting the code from okta server.</p>
  
  <pre><code>String url = "https://{org-url}/oauth2/default/v1/authorize?client_id=0oajaew0dq7rNU1uj0h7&amp;response_type=code&amp;scope=openid&amp;redirect_uri=http://localhost:8087/cisms/login&amp;state=state-296bc9a0-a2a2-4a57-be1a-d0e2fd9bb601";
  //      url = "https://www.google.co.in";
          try {
              System.setProperty("https.protocols", "TLSv1.1");
              HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
              connection.setRequestMethod("GET");
              int responseCode = connection.getResponseCode();
              System.out.println(responseCode);
          } catch (Exception e) {
              e.printStackTrace();
          }
  </code></pre>
  
  <p>I have added this line System.setProperty("https.protocols", "TLSv1.1"); from another link [<a href="https://stackoverflow.com/questions/28908835/ssl-peer-shut-down-incorrectly-in-java][1]">SSL peer shut down incorrectly in Java</a>
  But I got the following exception.</p>
  
  <pre><code>javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
      at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:953)
      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.radiant.cisms.test.activeMQ.TestQueue.main(TestQueue.java:69)
  Caused by: java.io.EOFException: SSL peer shut down incorrectly
      at sun.security.ssl.InputRecord.read(InputRecord.java:482)
      at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:934)
      ... 9 more
  </code></pre>
  
  <p>How can I overcome it. Is I have to add some certificate or not. I'm very much new to this. Any help would be appreciable.</p>