use of org.eclipse.jetty.server.SslConnectionFactory in project qi4j-sdk by Qi4j.
the class SecureJettyMixin method buildConnector.
@Override
protected ServerConnector buildConnector(Server server, HttpConfiguration httpConfig) {
SslConnectionFactory sslConnFactory = new SslConnectionFactory();
configureSsl(sslConnFactory, configuration.get());
return new ServerConnector(server, sslConnFactory, new HttpConnectionFactory(httpConfig));
}
use of org.eclipse.jetty.server.SslConnectionFactory in project sonarqube by SonarSource.
the class SSLTest method startSSLTransparentReverseProxy.
public static void startSSLTransparentReverseProxy(boolean requireClientAuth) throws Exception {
int httpPort = NetworkUtils.getNextAvailablePort();
httpsPort = NetworkUtils.getNextAvailablePort();
// Setup Threadpool
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(500);
server = new Server(threadPool);
// HTTP Configuration
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSecureScheme("https");
httpConfig.setSecurePort(httpsPort);
httpConfig.setSendServerVersion(true);
httpConfig.setSendDateHeader(false);
// Handler Structure
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] { proxyHandler(), new DefaultHandler() });
server.setHandler(handlers);
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
http.setPort(httpPort);
server.addConnector(http);
Path serverKeyStore = Paths.get(SSLTest.class.getResource("/analysis/SSLTest/serverkeystore.jks").toURI()).toAbsolutePath();
String keyStorePassword = "serverkeystorepwd";
String serverKeyPassword = "serverp12pwd";
Path serverTrustStore = Paths.get(SSLTest.class.getResource("/analysis/SSLTest/servertruststore.jks").toURI()).toAbsolutePath();
String trustStorePassword = "servertruststorepwd";
// SSL Context Factory
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath(serverKeyStore.toString());
sslContextFactory.setKeyStorePassword(keyStorePassword);
sslContextFactory.setKeyManagerPassword(serverKeyPassword);
sslContextFactory.setTrustStorePath(serverTrustStore.toString());
sslContextFactory.setTrustStorePassword(trustStorePassword);
sslContextFactory.setNeedClientAuth(requireClientAuth);
sslContextFactory.setExcludeCipherSuites("SSL_RSA_WITH_DES_CBC_SHA", "SSL_DHE_RSA_WITH_DES_CBC_SHA", "SSL_DHE_DSS_WITH_DES_CBC_SHA", "SSL_RSA_EXPORT_WITH_RC4_40_MD5", "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA");
// SSL HTTP Configuration
HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
// SSL Connector
ServerConnector sslConnector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(httpsConfig));
sslConnector.setPort(httpsPort);
server.addConnector(sslConnector);
server.start();
}
use of org.eclipse.jetty.server.SslConnectionFactory in project spark by perwendel.
the class SocketConnectorFactoryTest method testCreateSecureSocketConnector.
@Test
@PrepareForTest({ ServerConnector.class })
public void testCreateSecureSocketConnector() throws Exception {
final String host = "localhost";
final int port = 8888;
final String keystoreFile = "keystoreFile.jks";
final String keystorePassword = "keystorePassword";
final String truststoreFile = "truststoreFile.jks";
final String trustStorePassword = "trustStorePassword";
SslStores sslStores = SslStores.create(keystoreFile, keystorePassword, truststoreFile, trustStorePassword);
Server server = new Server();
ServerConnector serverConnector = SocketConnectorFactory.createSecureSocketConnector(server, host, port, sslStores);
String internalHost = Whitebox.getInternalState(serverConnector, "_host");
int internalPort = Whitebox.getInternalState(serverConnector, "_port");
assertEquals("Server Connector Host should be set to the specified server", host, internalHost);
assertEquals("Server Connector Port should be set to the specified port", port, internalPort);
Map<String, ConnectionFactory> factories = Whitebox.getInternalState(serverConnector, "_factories");
assertTrue("Should return true because factory for SSL should have been set", factories.containsKey("ssl") && factories.get("ssl") != null);
SslConnectionFactory sslConnectionFactory = (SslConnectionFactory) factories.get("ssl");
SslContextFactory sslContextFactory = sslConnectionFactory.getSslContextFactory();
assertEquals("Should return the Keystore file specified", keystoreFile, sslContextFactory.getKeyStoreResource().getFile().getName());
assertEquals("Should return the Truststore file specified", truststoreFile, sslContextFactory.getTrustStoreResource().getFile().getName());
}
use of org.eclipse.jetty.server.SslConnectionFactory in project neo4j by neo4j.
the class SslSocketConnectorFactory method createSslConnectionFactory.
private SslConnectionFactory createSslConnectionFactory(KeyStoreInformation ksInfo) {
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStore(ksInfo.getKeyStore());
sslContextFactory.setKeyStorePassword(String.valueOf(ksInfo.getKeyStorePassword()));
sslContextFactory.setKeyManagerPassword(String.valueOf(ksInfo.getKeyPassword()));
return new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString());
}
use of org.eclipse.jetty.server.SslConnectionFactory in project spring-boot by spring-projects.
the class JettyServletWebServerFactoryTests method sslEnabledMultiProtocolsConfiguration.
@Test
public void sslEnabledMultiProtocolsConfiguration() 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" });
ssl.setEnabledProtocols(new String[] { "TLSv1.1", "TLSv1.2" });
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().getIncludeProtocols()).isEqualTo(new String[] { "TLSv1.1", "TLSv1.2" });
}
Aggregations