I'm following the steps for autherisation of okta server with the below link. [https://developer.okta.com/authentication-guide/implementing-authentication/auth-code][1] 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.
String url = "https://{org-url}/oauth2/default/v1/authorize?client_id=0oajaew0dq7rNU1uj0h7&response_type=code&scope=openid&redirect_uri=http://localhost:8087/cisms/login&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();
}
I have added this line System.setProperty("https.protocols", "TLSv1.1"); from another link [SSL peer shut down incorrectly in Java But I got the following exception.
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
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.