连接到okta服务器时出现javax.net.ssl.SSLHandshakeException

时间:2019-02-13 05:36:32

标签: single-sign-on httpclient httpurlconnection okta sslhandshakeexception

我正在通过以下链接对okta服务器进行身份验证的步骤。 [https://developer.okta.com/authentication-guide/implementing-authentication/auth-code][1] 在第二步中,我们有一个get请求,以从okta获取代码。我在jboss服务器上使用jersey webservice。我有以下代码,用于从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 peer shut down incorrectly in 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

我该如何克服它。是否必须添加一些证书?我对此很陌生。任何帮助都是可观的。

0 个答案:

没有答案