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);
}
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);
}
}
}
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);
}
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
}
}
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
}
}
Aggregations