Я следую инструкциям по аутентификации на сервере okta по ссылке ниже.[https://developer.okta.com/authentication-guide/implementing-authentication/auth-code][1] На втором шаге у нас есть запрос на получение кода от okta.Я использую веб-сервис Джерси с сервером Jboss.У меня есть следующий код для получения кода с сервера okta.
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();
}
Я добавил эту строку System.setProperty ("https.protocols", "TLSv1.1");по другой ссылке [ SSL-узел некорректно завершает работу в Java Но я получил следующее исключение.
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
Как мне его преодолеть.Должен ли я добавить сертификат или нет.Я очень новичок в этом.Любая помощь будет заметна.