httpFactory.getProtocol()); return new AbstractConnectionFactory[] {sslFactory, httpFactory};
final HttpConfiguration httpConfig = new HttpConfiguration(); httpConfig.setSecurePort(httpsPort); final ServerConnector httpConnector = new ServerConnector(server, new HttpConnectionFactory(httpConfig)); httpConnector.setPort(httpPort); server.addConnector(httpConnector); final HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig); httpsConfig.addCustomizer(new SecureRequestCustomizer()); // !!! final HttpConnectionFactory httpsFactory = new HttpConnectionFactory(httpsConfig); final SslConnectionFactory sslFactory = new SslConnectionFactory(sslCtx, httpsFactory.getProtocol()); final ServerConnector httpsConnector = new ServerConnector(server, sslFactory, httpsFactory); httpsConnector.setPort(httpsPort); server.addConnector(httpsConnector);
factories.add(new SslConnectionFactory(ssl, http.getProtocol()));
@Override public ServerConnector create(Server server) { HttpConfiguration httpConfiguration = new HttpConfiguration(); httpConfiguration.setSendServerVersion(false); httpConfiguration.setSendXPoweredBy(false); HttpConnectionFactory https = new HttpConnectionFactory(httpConfiguration); SslContextFactory sslContextFactory = new ExternalCertificateSslContextFactory(certificateProviders); sslContextFactory.setCipherComparator(HTTP2Cipher.COMPARATOR); sslContextFactory.setUseCipherSuitesOrder(true); ServerConnector httpsConnector; try { ALPNServerConnectionFactory alpn = new ALPNServerConnectionFactory(); alpn.setDefaultProtocol("h2"); HTTP2ServerConnectionFactory h2 = new HTTP2ServerConnectionFactory(httpConfiguration); SslConnectionFactory ssl = new SslConnectionFactory(sslContextFactory, alpn.getProtocol()); httpsConnector = new ServerConnector(server, ssl, alpn, h2, https); } catch (IllegalStateException e) { //No ALPN SslConnectionFactory ssl = new SslConnectionFactory(sslContextFactory, https.getProtocol()); httpsConnector = new ServerConnector(server, ssl, https); } httpsConnector.setHost(ipPortPair.getIpAddress().toString()); httpsConnector.setPort(ipPortPair.getPort()); httpsConnector.setIdleTimeout(30000); return httpsConnector; } }
} else { SslConnectionFactory ssl = new SslConnectionFactory(sslContextFactory, http.getProtocol());
new TlsOrPlainConnectionFactory(sslContextFactory, httpConnectionFactory.getProtocol()); sslConnectionFactory = new SslConnectionFactory(sslContextFactory, httpConnectionFactory.getProtocol());