Search in sources :

Example 1 with SSLProtocolException

use of javax.net.ssl.SSLProtocolException in project intellij-community by JetBrains.

the class SSLExceptionParserTest method testRealLifeCase.

@Test
public void testRealLifeCase() throws Exception {
    final String original = "handshake alert:  unrecognized_name";
    final SSLProtocolException exception = new SSLProtocolException(original);
    final SSLProtocolExceptionParser parser = new SSLProtocolExceptionParser(exception.getMessage());
    parser.parse();
    final String message = parser.getParsedMessage();
    System.out.println(message);
    Assert.assertNotSame(original, message);
}
Also used : SSLProtocolException(javax.net.ssl.SSLProtocolException) SSLProtocolExceptionParser(org.jetbrains.idea.svn.networking.SSLProtocolExceptionParser) Test(org.junit.Test)

Example 2 with SSLProtocolException

use of javax.net.ssl.SSLProtocolException in project intellij-community by JetBrains.

the class SvnKitDebugLogger method handleSpecificSSLExceptions.

private void handleSpecificSSLExceptions(Throwable th) {
    final long time = System.currentTimeMillis();
    if ((time - myPreviousTime) <= ourErrorNotificationInterval) {
        return;
    }
    if (th instanceof SSLHandshakeException) {
        // not trusted certificate exception is not the problem, just part of normal behaviour
        if (th.getCause() instanceof SVNSSLUtil.CertificateNotTrustedException) {
            myLog.info(th);
            return;
        }
        myPreviousTime = time;
        String info = SSLExceptionsHelper.getAddInfo();
        info = info == null ? "" : " (" + info + ") ";
        if (th.getCause() instanceof CertificateException) {
            PopupUtil.showBalloonForActiveFrame("Subversion: " + info + th.getCause().getMessage(), MessageType.ERROR);
        } else {
            final String postMessage = "\nPlease check Subversion SSL settings (Settings | Version Control | Subversion | Network)\n" + "Maybe you should specify SSL protocol manually - SSLv3 or TLSv1";
            PopupUtil.showBalloonForActiveFrame("Subversion: " + info + th.getMessage() + postMessage, MessageType.ERROR);
        }
    } else if (th instanceof SSLProtocolException) {
        final String message = th.getMessage();
        if (!StringUtil.isEmptyOrSpaces(message)) {
            myPreviousTime = time;
            String info = SSLExceptionsHelper.getAddInfo();
            info = info == null ? "" : " (" + info + ") ";
            final SSLProtocolExceptionParser parser = new SSLProtocolExceptionParser(message);
            parser.parse();
            final String errMessage = "Subversion: " + info + parser.getParsedMessage();
            PopupUtil.showBalloonForActiveFrame(errMessage, MessageType.ERROR);
        }
    }
}
Also used : SSLProtocolException(javax.net.ssl.SSLProtocolException) SSLProtocolExceptionParser(org.jetbrains.idea.svn.networking.SSLProtocolExceptionParser) CertificateException(java.security.cert.CertificateException) SSLHandshakeException(javax.net.ssl.SSLHandshakeException)

Example 3 with SSLProtocolException

use of javax.net.ssl.SSLProtocolException in project robovm by robovm.

the class SSLRecordProtocol method wrap.

/**
     * Depending on the Connection State (Session) encrypts and compress
     * the provided data, and packs it into TLSCiphertext structure.
     * @param   content_type: int
     * @param   fragment: byte[]
     * @return  ssl packet created over the current connection state
     */
protected byte[] wrap(byte content_type, byte[] fragment, int offset, int len) {
    if (logger != null) {
        logger.println("SSLRecordProtocol.wrap: TLSPlaintext.fragment[" + len + "]:");
        logger.print(fragment, offset, len);
    }
    if (len > MAX_DATA_LENGTH) {
        throw new AlertException(AlertProtocol.INTERNAL_ERROR, new SSLProtocolException("The provided chunk of data is too big: " + len + " > MAX_DATA_LENGTH == " + MAX_DATA_LENGTH));
    }
    byte[] ciphered_fragment = fragment;
    if (activeWriteState != null) {
        ciphered_fragment = activeWriteState.encrypt(content_type, fragment, offset, len);
        if (ciphered_fragment.length > MAX_CIPHERED_DATA_LENGTH) {
            throw new AlertException(AlertProtocol.INTERNAL_ERROR, new SSLProtocolException("The ciphered data increased more than on 1024 bytes"));
        }
        if (logger != null) {
            logger.println("SSLRecordProtocol.wrap: TLSCiphertext.fragment[" + ciphered_fragment.length + "]:");
            logger.print(ciphered_fragment);
        }
    }
    return packetize(content_type, version, ciphered_fragment);
}
Also used : SSLProtocolException(javax.net.ssl.SSLProtocolException)

Example 4 with SSLProtocolException

use of javax.net.ssl.SSLProtocolException in project okhttp by square.

the class URLConnectionTest method testNoSslFallback.

@Test
public void testNoSslFallback() throws Exception {
    server.useHttps(sslClient.socketFactory, false);
    server.enqueue(new MockResponse().setSocketPolicy(FAIL_HANDSHAKE));
    server.enqueue(new MockResponse().setBody("Response that would have needed fallbacks"));
    HttpsURLConnection connection = (HttpsURLConnection) server.url("/").url().openConnection();
    connection.setSSLSocketFactory(sslClient.socketFactory);
    try {
        connection.getInputStream();
        fail();
    } catch (SSLProtocolException expected) {
    // RI response to the FAIL_HANDSHAKE
    } catch (SSLHandshakeException expected) {
    // Android's response to the FAIL_HANDSHAKE
    }
}
Also used : SSLProtocolException(javax.net.ssl.SSLProtocolException) MockResponse(okhttp3.mockwebserver.MockResponse) HttpsURLConnection(javax.net.ssl.HttpsURLConnection) SSLHandshakeException(javax.net.ssl.SSLHandshakeException) Test(org.junit.Test)

Example 5 with SSLProtocolException

use of javax.net.ssl.SSLProtocolException in project okhttp by square.

the class CallTest method noRecoveryFromTlsHandshakeFailureWhenTlsFallbackIsDisabled.

@Test
public void noRecoveryFromTlsHandshakeFailureWhenTlsFallbackIsDisabled() throws Exception {
    client = client.newBuilder().connectionSpecs(Arrays.asList(ConnectionSpec.MODERN_TLS, ConnectionSpec.CLEARTEXT)).hostnameVerifier(new RecordingHostnameVerifier()).dns(new SingleInetAddressDns()).sslSocketFactory(suppressTlsFallbackClientSocketFactory(), sslClient.trustManager).build();
    server.useHttps(sslClient.socketFactory, false);
    server.enqueue(new MockResponse().setSocketPolicy(SocketPolicy.FAIL_HANDSHAKE));
    Request request = new Request.Builder().url(server.url("/")).build();
    try {
        client.newCall(request).execute();
        fail();
    } catch (SSLProtocolException expected) {
    // RI response to the FAIL_HANDSHAKE
    } catch (SSLHandshakeException expected) {
    // Android's response to the FAIL_HANDSHAKE
    }
}
Also used : SSLProtocolException(javax.net.ssl.SSLProtocolException) MockResponse(okhttp3.mockwebserver.MockResponse) RecordedRequest(okhttp3.mockwebserver.RecordedRequest) SingleInetAddressDns(okhttp3.internal.SingleInetAddressDns) SSLHandshakeException(javax.net.ssl.SSLHandshakeException) Test(org.junit.Test)

Aggregations

SSLProtocolException (javax.net.ssl.SSLProtocolException)29 SSLHandshakeException (javax.net.ssl.SSLHandshakeException)6 IOException (java.io.IOException)3 BufferUnderflowException (java.nio.BufferUnderflowException)3 CertificateException (java.security.cert.CertificateException)3 SSLException (javax.net.ssl.SSLException)3 Test (org.junit.Test)3 HandshakeState (sun.security.ssl.HandshakeStateManager.HandshakeState)3 Buffer (java.nio.Buffer)2 ByteBuffer (java.nio.ByteBuffer)2 SecureRandom (java.security.SecureRandom)2 CertificateEncodingException (java.security.cert.CertificateEncodingException)2 X509Certificate (java.security.cert.X509Certificate)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 HttpsURLConnection (javax.net.ssl.HttpsURLConnection)2 SNIHostName (javax.net.ssl.SNIHostName)2 SNIServerName (javax.net.ssl.SNIServerName)2 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)2 X509TrustManager (javax.net.ssl.X509TrustManager)2