use of javax.net.ssl.SSLHandshakeException in project bnd by bndtools.
the class HttpConnectorTest method testConnectHTTPSBadCerficate.
public static void testConnectHTTPSBadCerficate() throws Exception {
DefaultURLConnector connector = new DefaultURLConnector();
InputStream stream = null;
try {
stream = connector.connect(new URL(getUrl(false) + "bundles/dummybundle.jar"));
fail("Expected SSLHandsakeException");
} catch (SSLHandshakeException e) {
// expected
} finally {
if (stream != null)
IO.close(stream);
}
}
use of javax.net.ssl.SSLHandshakeException in project rabbitmq-java-client by rabbitmq.
the class SslContextFactoryTest method doTestSetSslContextFactory.
private void doTestSetSslContextFactory(Supplier<ConnectionFactory> supplier) throws Exception {
ConnectionFactory connectionFactory = supplier.get();
SslContextFactory sslContextFactory = sslContextFactory();
connectionFactory.setSslContextFactory(sslContextFactory);
Connection connection = connectionFactory.newConnection("connection01");
TestUtils.close(connection);
try {
connectionFactory.newConnection("connection02");
fail("The SSL context of this client should not trust the server");
} catch (SSLHandshakeException e) {
// OK
}
}
use of javax.net.ssl.SSLHandshakeException in project dropbox-sdk-java by dropbox.
the class NetworkIOException method computeMessage.
private static String computeMessage(IOException ex) {
String message = ex.getMessage();
// useful for debugging.
if (ex instanceof SSLHandshakeException) {
Throwable innerCause = ex.getCause();
if (innerCause instanceof CertPathValidatorException) {
CertPathValidatorException cpve = (CertPathValidatorException) innerCause;
message += "[CERT PATH: " + cpve.getCertPath() + "]";
}
}
return message;
}
use of javax.net.ssl.SSLHandshakeException in project baseio by generallycloud.
the class SocketSelectorEventLoop method accept.
private void accept(NioSocketChannel channel) {
try {
ByteBuf buf = this.buf;
buf.clear();
buf.nioBuffer();
int length = channel.read(buf);
if (length < 1) {
if (length == -1) {
CloseUtil.close(channel);
}
return;
}
channel.active();
byteBufReader.accept(channel, buf.flip());
} catch (Throwable e) {
if (e instanceof SSLHandshakeException) {
// failed connect , the session should be null
getSelector().finishConnect(null, e);
}
closeSocketChannel(channel, e);
}
}
use of javax.net.ssl.SSLHandshakeException in project platform_frameworks_base by android.
the class TestUtils method assertUrlConnectionFails.
public static void assertUrlConnectionFails(SSLContext context, String host, int port) throws Exception {
URL url = new URL("https://" + host + ":" + port);
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setSSLSocketFactory(context.getSocketFactory());
try {
connection.getInputStream();
fail("Connection to " + host + ":" + port + " expected to fail");
} catch (SSLHandshakeException expected) {
// ignored.
}
}
Aggregations