Example usage for javax.net.ssl SSLHandshakeException toString

List of usage examples for javax.net.ssl SSLHandshakeException toString

Introduction

In this page you can find the example usage for javax.net.ssl SSLHandshakeException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:io.confluent.rest.SslTest.java

@Test(expected = SocketException.class)
public void testHttpsWithAuthAndNoClientCert() throws Exception {
    Properties props = new Properties();
    String uri = "https://localhost:8080";
    props.put(RestConfig.LISTENERS_CONFIG, uri);
    configServerKeystore(props);/*from  w w  w.j  av a  2  s  . c om*/
    configServerTruststore(props);
    enableSslClientAuth(props);
    TestRestConfig config = new TestRestConfig(props);
    SslTestApplication app = new SslTestApplication(config);
    try {
        app.start();
        try {
            makeGetRequest(uri + "/test");
        } catch (SSLHandshakeException she) {
            // JDK7 will throw the SHE, but JDK8 will throw the SE. This catch allows this code
            // to run on JDK7 and JDK8.
            throw new SocketException(she.toString());
        }
    } finally {
        app.stop();
    }
}

From source file:com.floragunn.searchguard.ssl.SSLTest.java

@Test
public void testHttpsEnforceFail() throws Exception {

    enableHTTPClientSSL = true;/*from   w ww  .j a  v  a2  s. co m*/
    trustHTTPServerCertificate = true;
    sendHTTPClientCertificate = false;

    final Settings settings = Settings.settingsBuilder().put("searchguard.ssl.transport.enabled", false)
            .put(SSLConfigConstants.SEARCHGUARD_SSL_HTTP_ENABLE_OPENSSL_IF_AVAILABLE, allowOpenSSL)
            .put(SSLConfigConstants.SEARCHGUARD_SSL_TRANSPORT_ENABLE_OPENSSL_IF_AVAILABLE, allowOpenSSL)
            .put(SSLConfigConstants.SEARCHGUARD_SSL_HTTP_KEYSTORE_ALIAS, "node-0")
            .put("searchguard.ssl.http.enabled", true).put("searchguard.ssl.http.clientauth_mode", "REQUIRE")
            .put("searchguard.ssl.http.keystore_filepath",
                    getAbsoluteFilePathFromClassPath("node-0-keystore.jks"))
            .put("searchguard.ssl.http.truststore_filepath", getAbsoluteFilePathFromClassPath("truststore.jks"))
            .build();

    startES(settings);
    try {
        executeSimpleRequest("");
        Assert.fail();
    } catch (SSLHandshakeException e) {
        //expected
        System.out.println("Expected SSLHandshakeException " + e.toString());
    } catch (SocketException e) {
        //expected
        System.out.println("Expected SocketException " + e.toString());
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("Unexpected exception " + e.toString());
    }
}