From aed886d8dea35f6dd4186a95a24f2e171ca559f1 Mon Sep 17 00:00:00 2001 From: ZHANG Dapeng Date: Mon, 2 May 2016 14:01:36 -0700 Subject: [PATCH] use Jetty ALPN agent instead of Jetty ALPN #1497 --- SECURITY.md | 8 ++++++-- benchmarks/build.gradle | 8 ++++---- build.gradle | 20 +++++++------------- interop-testing/build.gradle | 2 +- netty/build.gradle | 2 +- 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 35cb7e265c..b77d1620b2 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -217,13 +217,17 @@ dependencies { If not using the Netty transport (or you are unable to use OpenSSL for some reason) another alternative is to use the JDK for TLS. -No standard Java release has built-in support for ALPN today ([there is a tracking issue](https://bugs.openjdk.java.net/browse/JDK-8051498) so go upvote it!) so we need to use the [Jetty-ALPN](https://github.com/jetty-project/jetty-alpn") (or [Jetty-NPN](https://github.com/jetty-project/jetty-npn) if on Java < 8) bootclasspath extension for OpenJDK. To do this, add a `Xbootclasspath` JVM option referencing the path to the Jetty `alpn-boot` jar. +No standard Java release has built-in support for ALPN today ([there is a tracking issue](https://bugs.openjdk.java.net/browse/JDK-8051498) so go upvote it!) so we need to use the [Jetty-ALPN](https://github.com/jetty-project/jetty-alpn) (or [Jetty-NPN](https://github.com/jetty-project/jetty-npn) if on Java < 8) bootclasspath extension for OpenJDK. To do this, add an `Xbootclasspath` JVM option referencing the path to the Jetty `alpn-boot` jar. ```sh java -Xbootclasspath/p:/path/to/jetty/alpn/extension.jar ... ``` -Note that you must use the [release of the Jetty-ALPN jar](http://www.eclipse.org/jetty/documentation/current/alpn-chapter.html#alpn-versions) specific to the version of Java you are using. +Note that you must use the [release of the Jetty-ALPN jar](http://www.eclipse.org/jetty/documentation/current/alpn-chapter.html#alpn-versions) specific to the version of Java you are using. However, you can use the JVM agent [Jeety-ALPN-Agent](https://github.com/jetty-project/jetty-alpn-agent) to load the correct Jetty `alpn-boot` jar file for the current Java version. To do this, instead of adding an `Xbootclasspath` option, add a `javaagent` JVM option referencing the path to the Jetty `alpn-agent` jar. + +```sh +java -javaagent:/path/to/jetty-alpn-agent.jar ... +``` ### JDK Ciphers diff --git a/benchmarks/build.gradle b/benchmarks/build.gradle index 7a3c77a232..76649f7e0a 100644 --- a/benchmarks/build.gradle +++ b/benchmarks/build.gradle @@ -56,7 +56,7 @@ def vmArgs = [ task qps_client(type: CreateStartScripts) { mainClassName = "io.grpc.benchmarks.qps.AsyncClient" applicationName = "qps_client" - defaultJvmOpts = ["-Xbootclasspath/p:" + configurations.alpnboot.asPath] + vmArgs + defaultJvmOpts = ["-javaagent:" + configurations.alpnagent.asPath] + vmArgs outputDir = new File(project.buildDir, 'tmp') classpath = jar.outputs.files + project.configurations.runtime } @@ -64,7 +64,7 @@ task qps_client(type: CreateStartScripts) { task openloop_client(type: CreateStartScripts) { mainClassName = "io.grpc.benchmarks.qps.OpenLoopClient" applicationName = "openloop_client" - defaultJvmOpts = ["-Xbootclasspath/p:" + configurations.alpnboot.asPath] + vmArgs + defaultJvmOpts = ["-javaagent:" + configurations.alpnagent.asPath] + vmArgs outputDir = new File(project.buildDir, 'tmp') classpath = jar.outputs.files + project.configurations.runtime } @@ -72,7 +72,7 @@ task openloop_client(type: CreateStartScripts) { task qps_server(type: CreateStartScripts) { mainClassName = "io.grpc.benchmarks.qps.AsyncServer" applicationName = "qps_server" - defaultJvmOpts = ["-Xbootclasspath/p:" + configurations.alpnboot.asPath] + vmArgs + defaultJvmOpts = ["-javaagent:" + configurations.alpnagent.asPath] + vmArgs outputDir = new File(project.buildDir, 'tmp') classpath = jar.outputs.files + project.configurations.runtime } @@ -80,7 +80,7 @@ task qps_server(type: CreateStartScripts) { task benchmark_worker(type: CreateStartScripts) { mainClassName = "io.grpc.benchmarks.driver.LoadWorker" applicationName = "benchmark_worker" - defaultJvmOpts = ["-Xbootclasspath/p:" + configurations.alpnboot.asPath] + vmArgs + defaultJvmOpts = ["-javaagent:" + configurations.alpnagent.asPath] + vmArgs outputDir = new File(project.buildDir, 'tmp') classpath = jar.outputs.files + project.configurations.runtime } diff --git a/build.gradle b/build.gradle index 94b98382c2..9c2d3c3013 100644 --- a/build.gradle +++ b/build.gradle @@ -149,21 +149,15 @@ subprojects { // Benchmark dependencies hdrhistogram: 'org.hdrhistogram:HdrHistogram:2.1.8', math: 'org.apache.commons:commons-math3:3.6', + + // Jetty ALPN dependencies + jetty_alpn_agent: 'org.mortbay.jetty.alpn:jetty-alpn-agent:2.0.2' ] - - // Determine the correct version of Jetty ALPN boot to use based - // on the Java version. - def alpnboot_version = '8.1.2.v20141202' - if (JavaVersion.current().ordinal() < JavaVersion.VERSION_1_8.ordinal()) { - alpnboot_version = '7.1.3.v20150130' - } - - alpnboot_package_name = 'org.mortbay.jetty.alpn:alpn-boot:' + alpnboot_version } - // Define a separate configuration for managing the dependency on Jetty alpnboot jar. + // Define a separate configuration for managing the dependency on Jetty ALPN agent. configurations { - alpnboot + alpnagent tcnative } @@ -171,8 +165,8 @@ subprojects { testCompile libraries.junit, libraries.mockito - // Configuration for modules that use Jetty ALPN - alpnboot alpnboot_package_name + // Configuration for modules that use Jetty ALPN agent + alpnagent libraries.jetty_alpn_agent // Configuration for modules that use Netty tcnative (for OpenSSL). tcnative libraries.netty_tcnative diff --git a/interop-testing/build.gradle b/interop-testing/build.gradle index 43843ed45e..f910eec542 100644 --- a/interop-testing/build.gradle +++ b/interop-testing/build.gradle @@ -29,7 +29,7 @@ dependencies { test { // For the automated tests, use Jetty ALPN. - jvmArgs "-Xbootclasspath/p:" + configurations.alpnboot.asPath + jvmArgs "-javaagent:" + configurations.alpnagent.asPath } // The application plugin uses the distribution plugin and configures the jars to be diff --git a/netty/build.gradle b/netty/build.gradle index 7f76b0cc3d..4677048e29 100644 --- a/netty/build.gradle +++ b/netty/build.gradle @@ -9,7 +9,7 @@ dependencies { } test { - jvmArgs "-Xbootclasspath/p:" + configurations.alpnboot.asPath + jvmArgs "-javaagent:" + configurations.alpnagent.asPath } javadoc.options.links 'http://netty.io/4.1/api/'