This is an automated email from the ASF dual-hosted git repository. klease pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new 56703d0e160 Simplify creation of SSL context for WireMock Jetty server. (#9182) 56703d0e160 is described below commit 56703d0e160b21e0c436cf8bf86a82cc9bfcd1a6 Author: klease <38634989+kle...@users.noreply.github.com> AuthorDate: Fri Jan 20 16:48:16 2023 +0100 Simplify creation of SSL context for WireMock Jetty server. (#9182) Use the method JettyHttpServer.buildSslContextFactory in the new WireMock version to avoid having to override createHttpConnector. --- .../camel/component/rest/openapi/HttpsTest.java | 2 +- .../camel/component/rest/openapi/HttpsV3Test.java | 2 +- .../rest/openapi/WireMockJettyServerFactory.java | 36 ++-------------------- 3 files changed, 5 insertions(+), 35 deletions(-) diff --git a/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/HttpsTest.java b/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/HttpsTest.java index 64e6b2ab6c4..e92ab076931 100644 --- a/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/HttpsTest.java +++ b/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/HttpsTest.java @@ -67,7 +67,7 @@ public abstract class HttpsTest extends CamelTestSupport { protected static WireMockServer petstore = new WireMockServer( wireMockConfig().httpServerFactory(new WireMockJettyServerFactory()).containerThreads(13).dynamicPort() .dynamicHttpsPort().keystorePath(Resources.getResource("localhost.p12").toString()).keystoreType("PKCS12") - .keystorePassword("changeit")); + .keystorePassword("changeit").keyManagerPassword("changeit")); static final Object NO_BODY = null; diff --git a/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/HttpsV3Test.java b/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/HttpsV3Test.java index b44f0e0a5be..516f5a48333 100644 --- a/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/HttpsV3Test.java +++ b/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/HttpsV3Test.java @@ -67,7 +67,7 @@ public abstract class HttpsV3Test extends CamelTestSupport { public static WireMockServer petstore = new WireMockServer( wireMockConfig().httpServerFactory(new WireMockJettyServerFactory()).containerThreads(13).dynamicPort() .dynamicHttpsPort().keystorePath(Resources.getResource("localhost.p12").toString()).keystoreType("PKCS12") - .keystorePassword("changeit")); + .keystorePassword("changeit").keyManagerPassword("changeit")); static final Object NO_BODY = null; diff --git a/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/WireMockJettyServerFactory.java b/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/WireMockJettyServerFactory.java index baf65a13041..08ddeadf1d7 100644 --- a/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/WireMockJettyServerFactory.java +++ b/components/camel-rest-openapi/src/test/java/org/apache/camel/component/rest/openapi/WireMockJettyServerFactory.java @@ -16,21 +16,12 @@ */ package org.apache.camel.component.rest.openapi; -import com.github.tomakehurst.wiremock.common.HttpsSettings; -import com.github.tomakehurst.wiremock.common.JettySettings; import com.github.tomakehurst.wiremock.core.Options; import com.github.tomakehurst.wiremock.http.AdminRequestHandler; import com.github.tomakehurst.wiremock.http.HttpServer; import com.github.tomakehurst.wiremock.http.StubRequestHandler; import com.github.tomakehurst.wiremock.jetty.JettyHttpServer; import com.github.tomakehurst.wiremock.jetty.JettyHttpServerFactory; -import org.eclipse.jetty.io.NetworkTrafficListener; -import org.eclipse.jetty.server.HttpConfiguration; -import org.eclipse.jetty.server.HttpConnectionFactory; -import org.eclipse.jetty.server.SecureRequestCustomizer; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.ServerConnector; -import org.eclipse.jetty.server.SslConnectionFactory; import org.eclipse.jetty.util.ssl.SslContextFactory; /** @@ -44,32 +35,11 @@ public final class WireMockJettyServerFactory extends JettyHttpServerFactory { return new JettyHttpServer(options, adminRequestHandler, stubRequestHandler) { @Override - protected ServerConnector createHttpsConnector( - Server server, - final String bindAddress, final HttpsSettings httpsSettings, - final JettySettings jettySettings, final NetworkTrafficListener listener) { - final SslContextFactory.Server sslContextFactory = new SslContextFactory.Server(); - - sslContextFactory.setKeyStorePath(httpsSettings.keyStorePath()); - sslContextFactory.setKeyManagerPassword(httpsSettings.keyStorePassword()); - sslContextFactory.setKeyStorePassword(httpsSettings.keyStorePassword()); - sslContextFactory.setKeyStoreType(httpsSettings.keyStoreType()); - if (httpsSettings.hasTrustStore()) { - sslContextFactory.setTrustStorePath(httpsSettings.trustStorePath()); - sslContextFactory.setTrustStorePassword(httpsSettings.trustStorePassword()); - sslContextFactory.setTrustStoreType(httpsSettings.trustStoreType()); - } - sslContextFactory.setNeedClientAuth(httpsSettings.needClientAuth()); + protected SslContextFactory.Server buildSslContextFactory() { + SslContextFactory.Server sslContextFactory = super.buildSslContextFactory(); sslContextFactory.setIncludeCipherSuites("TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"); sslContextFactory.setProtocol("TLSv1.3"); - - final HttpConfiguration httpConfig = createHttpConfig(jettySettings); - httpConfig.addCustomizer(new SecureRequestCustomizer()); - - final int port = httpsSettings.port(); - - return createServerConnector(bindAddress, jettySettings, port, listener, - new SslConnectionFactory(sslContextFactory, "http/1.1"), new HttpConnectionFactory(httpConfig)); + return sslContextFactory; } }; }