Search in sources :

Example 66 with SslContextFactory

use of org.eclipse.jetty.util.ssl.SslContextFactory in project zeppelin by apache.

the class ZeppelinhubClient method createNewWebsocketClient.

private WebSocketClient createNewWebsocketClient() {
    SslContextFactory sslContextFactory = new SslContextFactory();
    WebSocketClient client = new WebSocketClient(sslContextFactory);
    client.setMaxTextMessageBufferSize(Client.getMaxNoteSize());
    client.getPolicy().setMaxTextMessageSize(Client.getMaxNoteSize());
    client.setMaxIdleTimeout(CONNECTION_IDLE_TIME);
    return client;
}
Also used : SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) WebSocketClient(org.eclipse.jetty.websocket.client.WebSocketClient)

Example 67 with SslContextFactory

use of org.eclipse.jetty.util.ssl.SslContextFactory in project zeppelin by apache.

the class ZeppelinServer method getSslContextFactory.

private static SslContextFactory getSslContextFactory(ZeppelinConfiguration conf) {
    SslContextFactory sslContextFactory = new SslContextFactory();
    // Set keystore
    sslContextFactory.setKeyStorePath(conf.getKeyStorePath());
    sslContextFactory.setKeyStoreType(conf.getKeyStoreType());
    sslContextFactory.setKeyStorePassword(conf.getKeyStorePassword());
    sslContextFactory.setKeyManagerPassword(conf.getKeyManagerPassword());
    if (conf.useClientAuth()) {
        sslContextFactory.setNeedClientAuth(conf.useClientAuth());
        // Set truststore
        sslContextFactory.setTrustStorePath(conf.getTrustStorePath());
        sslContextFactory.setTrustStoreType(conf.getTrustStoreType());
        sslContextFactory.setTrustStorePassword(conf.getTrustStorePassword());
    }
    return sslContextFactory;
}
Also used : SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory)

Example 68 with SslContextFactory

use of org.eclipse.jetty.util.ssl.SslContextFactory in project hive by apache.

the class HttpServer method createChannelConnector.

/**
   * Create a channel connector for "http/https" requests
   */
Connector createChannelConnector(int queueSize, Builder b) {
    SelectChannelConnector connector;
    if (!b.useSSL) {
        connector = new SelectChannelConnector();
    } else {
        SslContextFactory sslContextFactory = new SslContextFactory();
        sslContextFactory.setKeyStorePath(b.keyStorePath);
        Set<String> excludedSSLProtocols = Sets.newHashSet(Splitter.on(",").trimResults().omitEmptyStrings().split(Strings.nullToEmpty(b.conf.getVar(ConfVars.HIVE_SSL_PROTOCOL_BLACKLIST))));
        sslContextFactory.addExcludeProtocols(excludedSSLProtocols.toArray(new String[excludedSSLProtocols.size()]));
        sslContextFactory.setKeyStorePassword(b.keyStorePassword);
        connector = new SslSelectChannelConnector(sslContextFactory);
    }
    connector.setLowResourcesMaxIdleTime(10000);
    connector.setAcceptQueueSize(queueSize);
    connector.setResolveNames(false);
    connector.setUseDirectBuffers(false);
    connector.setRequestHeaderSize(1024 * 64);
    connector.setReuseAddress(true);
    return connector;
}
Also used : SelectChannelConnector(org.eclipse.jetty.server.nio.SelectChannelConnector) SslSelectChannelConnector(org.eclipse.jetty.server.ssl.SslSelectChannelConnector) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) SslSelectChannelConnector(org.eclipse.jetty.server.ssl.SslSelectChannelConnector)

Example 69 with SslContextFactory

use of org.eclipse.jetty.util.ssl.SslContextFactory in project dropwizard by dropwizard.

the class Http2ConnectorFactory method build.

@Override
public Connector build(Server server, MetricRegistry metrics, String name, ThreadPool threadPool) {
    // HTTP/2 requires that a server MUST support TLSv1.2 and TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 cipher
    // See http://http2.github.io/http2-spec/index.html#rfc.section.9.2.2
    setSupportedProtocols(ImmutableList.of("TLSv1.2"));
    setSupportedCipherSuites(ImmutableList.of("TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"));
    // Setup connection factories
    final HttpConfiguration httpConfig = buildHttpConfiguration();
    final HttpConnectionFactory http1 = buildHttpConnectionFactory(httpConfig);
    final HTTP2ServerConnectionFactory http2 = new HTTP2ServerConnectionFactory(httpConfig);
    http2.setMaxConcurrentStreams(maxConcurrentStreams);
    http2.setInitialStreamRecvWindow(initialStreamRecvWindow);
    final NegotiatingServerConnectionFactory alpn = new ALPNServerConnectionFactory(H2, H2_17);
    // Speak HTTP 1.1 over TLS if negotiation fails
    alpn.setDefaultProtocol(HTTP_1_1);
    final SslContextFactory sslContextFactory = configureSslContextFactory(new SslContextFactory());
    sslContextFactory.addLifeCycleListener(logSslInfoOnStart(sslContextFactory));
    server.addBean(sslContextFactory);
    server.addBean(new SslReload(sslContextFactory, this::configureSslContextFactory));
    // We should use ALPN as a negotiation protocol. Old clients that don't support it will be served
    // via HTTPS. New clients, however, that want to use HTTP/2 will use TLS with ALPN extension.
    // If negotiation succeeds, the client and server switch to HTTP/2 protocol.
    final SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(sslContextFactory, "alpn");
    return buildConnector(server, new ScheduledExecutorScheduler(), buildBufferPool(), name, threadPool, new Jetty93InstrumentedConnectionFactory(sslConnectionFactory, metrics.timer(httpConnections())), alpn, http2, http1);
}
Also used : SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) SslReload(io.dropwizard.jetty.SslReload) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) ALPNServerConnectionFactory(org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory) ScheduledExecutorScheduler(org.eclipse.jetty.util.thread.ScheduledExecutorScheduler) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) HTTP2ServerConnectionFactory(org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory) NegotiatingServerConnectionFactory(org.eclipse.jetty.server.NegotiatingServerConnectionFactory) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) Jetty93InstrumentedConnectionFactory(io.dropwizard.jetty.Jetty93InstrumentedConnectionFactory)

Example 70 with SslContextFactory

use of org.eclipse.jetty.util.ssl.SslContextFactory in project dropwizard by dropwizard.

the class HttpsConnectorFactoryTest method windowsKeyStoreUnavailableThrowsException.

@Test(expected = IllegalStateException.class)
public void windowsKeyStoreUnavailableThrowsException() throws Exception {
    assumeFalse(canAccessWindowsKeyStore());
    final HttpsConnectorFactory factory = new HttpsConnectorFactory();
    factory.setKeyStoreType(WINDOWS_MY_KEYSTORE_NAME);
    factory.configureSslContextFactory(new SslContextFactory());
}
Also used : SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) Test(org.junit.Test)

Aggregations

SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)139 ServerConnector (org.eclipse.jetty.server.ServerConnector)54 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)44 Server (org.eclipse.jetty.server.Server)43 SslConnectionFactory (org.eclipse.jetty.server.SslConnectionFactory)43 Test (org.junit.Test)40 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)37 SecureRequestCustomizer (org.eclipse.jetty.server.SecureRequestCustomizer)35 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)23 InputStream (java.io.InputStream)18 IOException (java.io.IOException)17 File (java.io.File)15 SSLContext (javax.net.ssl.SSLContext)15 ServletException (javax.servlet.ServletException)15 OutputStream (java.io.OutputStream)14 HttpServletRequest (javax.servlet.http.HttpServletRequest)13 HttpServletResponse (javax.servlet.http.HttpServletResponse)13 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)13 AbstractHandler (org.eclipse.jetty.server.handler.AbstractHandler)11 InetSocketAddress (java.net.InetSocketAddress)10