Search in sources :

Example 41 with SslConnectionFactory

use of org.eclipse.jetty.server.SslConnectionFactory in project spring-boot by spring-projects.

the class JettyServletWebServerFactoryTests method sslCiphersConfiguration.

@Test
public void sslCiphersConfiguration() throws Exception {
    Ssl ssl = new Ssl();
    ssl.setKeyStore("src/test/resources/test.jks");
    ssl.setKeyStorePassword("secret");
    ssl.setKeyPassword("password");
    ssl.setCiphers(new String[] { "ALPHA", "BRAVO", "CHARLIE" });
    JettyServletWebServerFactory factory = getFactory();
    factory.setSsl(ssl);
    this.webServer = factory.getWebServer();
    this.webServer.start();
    JettyWebServer jettyWebServer = (JettyWebServer) this.webServer;
    ServerConnector connector = (ServerConnector) jettyWebServer.getServer().getConnectors()[0];
    SslConnectionFactory connectionFactory = connector.getConnectionFactory(SslConnectionFactory.class);
    assertThat(connectionFactory.getSslContextFactory().getIncludeCipherSuites()).containsExactly("ALPHA", "BRAVO", "CHARLIE");
    assertThat(connectionFactory.getSslContextFactory().getExcludeCipherSuites()).isEmpty();
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) Ssl(org.springframework.boot.web.server.Ssl) Test(org.junit.Test)

Example 42 with SslConnectionFactory

use of org.eclipse.jetty.server.SslConnectionFactory in project spring-boot by spring-projects.

the class JettyServletWebServerFactory method createSslConnector.

private AbstractConnector createSslConnector(Server server, SslContextFactory sslContextFactory, int port) {
    HttpConfiguration config = new HttpConfiguration();
    config.setSendServerVersion(false);
    config.addCustomizer(new SecureRequestCustomizer());
    HttpConnectionFactory connectionFactory = new HttpConnectionFactory(config);
    SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString());
    ServerConnector serverConnector = new ServerConnector(server, sslConnectionFactory, connectionFactory);
    serverConnector.setPort(port);
    return serverConnector;
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) SecureRequestCustomizer(org.eclipse.jetty.server.SecureRequestCustomizer) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory)

Example 43 with SslConnectionFactory

use of org.eclipse.jetty.server.SslConnectionFactory in project async-http-client by AsyncHttpClient.

the class TestUtils method addHttpsConnector.

public static ServerConnector addHttpsConnector(Server server) throws IOException, URISyntaxException {
    String keyStoreFile = resourceAsFile("ssltest-keystore.jks").getAbsolutePath();
    SslContextFactory sslContextFactory = new SslContextFactory(keyStoreFile);
    sslContextFactory.setKeyStorePassword("changeit");
    String trustStoreFile = resourceAsFile("ssltest-cacerts.jks").getAbsolutePath();
    sslContextFactory.setTrustStorePath(trustStoreFile);
    sslContextFactory.setTrustStorePassword("changeit");
    HttpConfiguration httpsConfig = new HttpConfiguration();
    httpsConfig.setSecureScheme("https");
    httpsConfig.addCustomizer(new SecureRequestCustomizer());
    ServerConnector connector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, "http/1.1"), new HttpConnectionFactory(httpsConfig));
    server.addConnector(connector);
    return connector;
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) SecureRequestCustomizer(org.eclipse.jetty.server.SecureRequestCustomizer) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory)

Example 44 with SslConnectionFactory

use of org.eclipse.jetty.server.SslConnectionFactory in project symmetric-ds by JumpMind.

the class SymmetricWebServer method getConnectors.

protected Connector[] getConnectors(Server server, int port, int securePort, Mode mode) {
    ArrayList<Connector> connectors = new ArrayList<Connector>();
    HttpConfiguration httpConfig = new HttpConfiguration();
    if (mode.equals(Mode.HTTPS) || mode.equals(Mode.MIXED)) {
        httpConfig.setSecureScheme("https");
        httpConfig.setSecurePort(securePort);
    }
    httpConfig.setOutputBufferSize(32768);
    if (mode.equals(Mode.HTTP) || mode.equals(Mode.MIXED)) {
        ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
        http.setPort(port);
        http.setHost(host);
        http.setIdleTimeout(maxIdleTime);
        connectors.add(http);
        log.info(String.format("About to start %s web server on host:port %s:%s", name, host == null ? "default" : host, port));
    }
    if (mode.equals(Mode.HTTPS) || mode.equals(Mode.MIXED)) {
        ISecurityService securityService = SecurityServiceFactory.create(SecurityServiceType.SERVER, new TypedProperties(System.getProperties()));
        securityService.installDefaultSslCert(host);
        String keyStorePassword = System.getProperty(SecurityConstants.SYSPROP_KEYSTORE_PASSWORD);
        keyStorePassword = (keyStorePassword != null) ? keyStorePassword : SecurityConstants.KEYSTORE_PASSWORD;
        SslContextFactory sslConnectorFactory = new SslContextFactory();
        sslConnectorFactory.setKeyManagerPassword(keyStorePassword);
        /* Prevent POODLE attack */
        String ignoredProtocols = System.getProperty(SecurityConstants.SYSPROP_SSL_IGNORE_PROTOCOLS);
        if (ignoredProtocols != null && ignoredProtocols.length() > 0) {
            String[] protocols = ignoredProtocols.split(",");
            sslConnectorFactory.addExcludeProtocols(protocols);
        } else {
            sslConnectorFactory.addExcludeProtocols("SSLv3");
        }
        String ignoredCiphers = System.getProperty(SecurityConstants.SYSPROP_SSL_IGNORE_CIPHERS);
        if (ignoredCiphers != null && ignoredCiphers.length() > 0) {
            String[] ciphers = ignoredCiphers.split(",");
            sslConnectorFactory.addExcludeCipherSuites(ciphers);
        }
        sslConnectorFactory.setCertAlias(System.getProperty(SecurityConstants.SYSPROP_KEYSTORE_CERT_ALIAS, SecurityConstants.ALIAS_SYM_PRIVATE_KEY));
        sslConnectorFactory.setKeyStore(securityService.getKeyStore());
        sslConnectorFactory.setTrustStore(securityService.getTrustStore());
        HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
        httpsConfig.addCustomizer(new SecureRequestCustomizer());
        ServerConnector https = new ServerConnector(server, new SslConnectionFactory(sslConnectorFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(httpsConfig));
        https.setPort(securePort);
        https.setIdleTimeout(maxIdleTime);
        https.setHost(host);
        connectors.add(https);
        log.info(String.format("About to start %s web server on secure host:port %s:%s", name, host == null ? "default" : host, securePort));
    }
    return connectors.toArray(new Connector[connectors.size()]);
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) Connector(org.eclipse.jetty.server.Connector) SecureRequestCustomizer(org.eclipse.jetty.server.SecureRequestCustomizer) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) ArrayList(java.util.ArrayList) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) TypedProperties(org.jumpmind.properties.TypedProperties) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) ServerConnector(org.eclipse.jetty.server.ServerConnector) ISecurityService(org.jumpmind.security.ISecurityService) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory)

Example 45 with SslConnectionFactory

use of org.eclipse.jetty.server.SslConnectionFactory in project voltdb by VoltDB.

the class HTTPAdminListener method getSSLServerConnector.

private ServerConnector getSSLServerConnector(SslContextFactory sslContextFactory, String intf, int port) throws IOException {
    // SSL HTTP Configuration
    HttpConfiguration httpsConfig = new HttpConfiguration();
    httpsConfig.setSecureScheme("ssl");
    httpsConfig.setSecurePort(port);
    //Add this customizer to indicate we are in ssl land
    httpsConfig.addCustomizer(new SecureRequestCustomizer());
    HttpConnectionFactory factory = new HttpConnectionFactory(httpsConfig);
    // SSL Connector
    ServerConnector connector = new ServerConnector(m_server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), factory);
    if (intf != null && !intf.trim().isEmpty()) {
        connector.setHost(intf);
    }
    connector.setPort(port);
    connector.setName("VoltDB-HTTPS");
    connector.open();
    return connector;
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) SecureRequestCustomizer(org.eclipse.jetty.server.SecureRequestCustomizer) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory)

Aggregations

SslConnectionFactory (org.eclipse.jetty.server.SslConnectionFactory)51 ServerConnector (org.eclipse.jetty.server.ServerConnector)48 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)44 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)41 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)40 SecureRequestCustomizer (org.eclipse.jetty.server.SecureRequestCustomizer)37 Server (org.eclipse.jetty.server.Server)30 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)11 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)8 File (java.io.File)7 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)7 HTTP2ServerConnectionFactory (org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory)6 Test (org.junit.Test)6 ServletException (javax.servlet.ServletException)5 ALPNServerConnectionFactory (org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory)5 ConnectionFactory (org.eclipse.jetty.server.ConnectionFactory)5 DefaultHandler (org.eclipse.jetty.server.handler.DefaultHandler)5 FileNotFoundException (java.io.FileNotFoundException)4 IOException (java.io.IOException)4 URI (java.net.URI)4