Merged branch 'jetty-11.0.x' into 'jetty-12.0.x'.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2023-11-08 13:35:46 +01:00
commit 236061ea29
No known key found for this signature in database
GPG Key ID: 1677D141BCF3584D
4 changed files with 53 additions and 9 deletions

View File

@ -164,7 +164,9 @@ For more information about the configuration of the `ssl-reload` Jetty module, s
[[og-protocols-ssl-conscrypt]]
===== Using Conscrypt as SSL/TLS Provider
By default, the standard TLS provider that comes with the JDK is used.
If not explicitly configured, the TLS implementation is provided by the JDK you are using at runtime.
OpenJDK's vendors may replace the default TLS provider with their own, but you can also explicitly configure an alternative TLS provider.
The standard TLS provider from OpenJDK is implemented in Java (no native code), and its performance is not optimal, both in CPU usage and memory usage.

View File

@ -102,13 +102,15 @@ include::../../{doc_code}/org/eclipse/jetty/docs/programming/server/http/HTTPSer
[[pg-server-http-connector-protocol-http11-tls]]
====== Encrypted HTTP/1.1 (https)
Supporting encrypted HTTP/1.1 (that is, requests with the `https` scheme) is supported by configuring an `SslContextFactory` that has access to the keyStore containing the private server key and public server certificate, in this way:
Supporting encrypted HTTP/1.1 (that is, requests with the `https` scheme) is supported by configuring an `SslContextFactory` that has access to the KeyStore containing the private server key and public server certificate, in this way:
[source,java,indent=0]
----
include::../../{doc_code}/org/eclipse/jetty/docs/programming/server/http/HTTPServerDocs.java[tags=tlsHttp11]
----
You can customize the SSL/TLS provider as explained in xref:pg-server-http-connector-protocol-tls-conscrypt[this section].
[[pg-server-http-connector-protocol-http2]]
====== Clear-Text HTTP/2
@ -153,6 +155,8 @@ The fact that the HTTP/2 protocol comes before the HTTP/1.1 protocol indicates t
Note also that the default protocol set in the ALPN ``ConnectionFactory``, which is used in case ALPN is not supported by the client, is HTTP/1.1 -- if the client does not support ALPN is probably an old client so HTTP/1.1 is the safest choice.
You can customize the SSL/TLS provider as explained in xref:pg-server-http-connector-protocol-tls-conscrypt[this section].
[[pg-server-http-connector-protocol-http3]]
====== HTTP/3
@ -198,6 +202,28 @@ To setup HTTP/3, for example on port `843`, you need the following code (some of
include::../../{doc_code}/org/eclipse/jetty/docs/programming/server/http/HTTPServerDocs.java[tags=h3]
----
[[pg-server-http-connector-protocol-tls-conscrypt]]
====== Using Conscrypt as SSL/TLS Provider
If not explicitly configured, the TLS implementation is provided by the JDK you are using at runtime.
OpenJDK's vendors may replace the default TLS provider with their own, but you can also explicitly configure an alternative TLS provider.
The standard TLS provider from OpenJDK is implemented in Java (no native code), and its performance is not optimal, both in CPU usage and memory usage.
A faster alternative, implemented natively, is Google's link:https://github.com/google/conscrypt/[Conscrypt], which is built on link:https://boringssl.googlesource.com/boringssl/[BoringSSL], which is Google's fork of link:https://www.openssl.org/[OpenSSL].
CAUTION: As Conscrypt eventually binds to a native library, there is a higher risk that a bug in Conscrypt or in the native library causes a JVM crash, while the Java implementation will not cause a JVM crash.
To use Conscrypt as TLS provider, you must have the Conscrypt jar and the Jetty dependency `jetty-alpn-conscrypt-server-{version}.jar` in the class-path or module-path.
Then, you must configure the JDK with the Conscrypt provider, and configure Jetty to use the Conscrypt provider, in this way:
[source,java,indent=0]
----
include::../../{doc_code}/org/eclipse/jetty/docs/programming/server/http/HTTPServerDocs.java[tags=conscrypt]
----
[[pg-server-http-connector-protocol-proxy-http11]]
====== Jetty Behind a Load Balancer

View File

@ -16,6 +16,7 @@ package org.eclipse.jetty.docs.programming.server.http;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.file.Path;
import java.security.Security;
import java.time.Duration;
import java.util.EnumSet;
import java.util.List;
@ -27,6 +28,7 @@ import jakarta.servlet.ServletInputStream;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.conscrypt.OpenSSLProvider;
import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory;
import org.eclipse.jetty.ee10.servlet.DefaultServlet;
import org.eclipse.jetty.ee10.servlet.FilterHolder;
@ -439,6 +441,20 @@ public class HTTPServerDocs
// end::h3[]
}
public void conscrypt()
{
// tag::conscrypt[]
// Configure the JDK with the Conscrypt provider.
Security.addProvider(new OpenSSLProvider());
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
sslContextFactory.setKeyStorePath("/path/to/keystore");
sslContextFactory.setKeyStorePassword("secret");
// Configure Jetty's SslContextFactory to use Conscrypt.
sslContextFactory.setProvider("Conscrypt");
// end::conscrypt[]
}
public void handlerTree()
{
class LoggingHandler extends Handler.Abstract

14
pom.xml
View File

@ -169,7 +169,7 @@
<commons-codec.version>1.16.0</commons-codec.version>
<commons-lang3.version>3.13.0</commons-lang3.version>
<commons.compress.version>1.24.0</commons.compress.version>
<commons.io.version>2.14.0</commons.io.version>
<commons.io.version>2.15.0</commons.io.version>
<compiler.release>17</compiler.release>
<compiler.source>17</compiler.source>
<compiler.target>17</compiler.target>
@ -259,15 +259,15 @@
<mariadb.version>3.2.0</mariadb.version>
<maven-artifact-transfer.version>0.13.1</maven-artifact-transfer.version>
<maven-build-cache.version>1.0.1</maven-build-cache.version>
<maven-plugin.plugin.version>3.9.0</maven-plugin.plugin.version>
<maven-plugin.plugin.version>3.10.1</maven-plugin.plugin.version>
<maven.antrun.plugin.version>3.1.0</maven.antrun.plugin.version>
<maven.assembly.plugin.version>3.6.0</maven.assembly.plugin.version>
<maven.bundle.plugin.version>5.1.9</maven.bundle.plugin.version>
<maven.checkstyle.plugin.version>3.3.0</maven.checkstyle.plugin.version>
<maven.clean.plugin.version>3.3.1</maven.clean.plugin.version>
<maven.checkstyle.plugin.version>3.3.1</maven.checkstyle.plugin.version>
<maven.clean.plugin.version>3.3.2</maven.clean.plugin.version>
<maven.compiler.createMissingPackageInfoClass>false</maven.compiler.createMissingPackageInfoClass>
<maven.compiler.plugin.version>3.11.0</maven.compiler.plugin.version>
<maven.dependency.plugin.version>3.6.0</maven.dependency.plugin.version>
<maven.dependency.plugin.version>3.6.1</maven.dependency.plugin.version>
<maven.deploy.plugin.version>3.1.1</maven.deploy.plugin.version>
<maven.deps.version>3.9.4</maven.deps.version>
<maven.enforcer.plugin.version>3.4.1</maven.enforcer.plugin.version>
@ -277,14 +277,14 @@
<maven.invoker.plugin.version>3.6.0</maven.invoker.plugin.version>
<maven.jar.plugin.version>3.3.0</maven.jar.plugin.version>
<maven.javadoc.plugin.version>3.6.0</maven.javadoc.plugin.version>
<maven.plugin-tools.version>3.9.0</maven.plugin-tools.version>
<maven.plugin-tools.version>3.10.1</maven.plugin-tools.version>
<maven.release.plugin.version>3.0.1</maven.release.plugin.version>
<maven.remote-resources-plugin.version>3.1.0</maven.remote-resources-plugin.version>
<maven.resolver.version>1.9.16</maven.resolver.version>
<maven.resources.plugin.version>3.3.1</maven.resources.plugin.version>
<maven.shade.plugin.version>3.5.1</maven.shade.plugin.version>
<maven.source.plugin.version>3.3.0</maven.source.plugin.version>
<maven.surefire.plugin.version>3.1.2</maven.surefire.plugin.version>
<maven.surefire.plugin.version>3.2.1</maven.surefire.plugin.version>
<maven.version>3.9.0</maven.version>
<maven.war.plugin.version>3.4.0</maven.war.plugin.version>
<mina.core.version>2.2.3</mina.core.version>