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:
commit
825fc6df1f
|
@ -0,0 +1,116 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others.
|
||||
//
|
||||
// This program and the accompanying materials are made available under the
|
||||
// terms of the Eclipse Public License v. 2.0 which is available at
|
||||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
|
||||
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
|
||||
//
|
||||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.http3.tests;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.security.KeyStore;
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
||||
import org.eclipse.jetty.http3.server.HTTP3ServerConnectionFactory;
|
||||
import org.eclipse.jetty.http3.server.HTTP3ServerConnector;
|
||||
import org.eclipse.jetty.server.HttpConfiguration;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
|
||||
import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
|
||||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
@ExtendWith(WorkDirExtension.class)
|
||||
public class HTTP3ServerConnectorTest
|
||||
{
|
||||
public WorkDir workDir;
|
||||
|
||||
@Test
|
||||
public void testStartHTTP3ServerConnectorWithoutKeyStore()
|
||||
{
|
||||
Server server = new Server();
|
||||
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
|
||||
HTTP3ServerConnector connector = new HTTP3ServerConnector(server, sslContextFactory, new HTTP3ServerConnectionFactory(new HttpConfiguration()));
|
||||
connector.getQuicConfiguration().setPemWorkDirectory(workDir.getEmptyPathDir());
|
||||
server.addConnector(connector);
|
||||
assertThrows(IllegalStateException.class, server::start);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartHTTP3ServerConnectorWithoutKeyStoreWithSSLContext() throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
|
||||
sslContextFactory.setSslContext(SSLContext.getDefault());
|
||||
HTTP3ServerConnector connector = new HTTP3ServerConnector(server, sslContextFactory, new HTTP3ServerConnectionFactory(new HttpConfiguration()));
|
||||
connector.getQuicConfiguration().setPemWorkDirectory(workDir.getEmptyPathDir());
|
||||
server.addConnector(connector);
|
||||
assertThrows(IllegalStateException.class, server::start);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartHTTP3ServerConnectorWithEmptyKeyStoreInstance() throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
keyStore.load(null, null);
|
||||
sslContextFactory.setKeyStore(keyStore);
|
||||
HTTP3ServerConnector connector = new HTTP3ServerConnector(server, sslContextFactory, new HTTP3ServerConnectionFactory(new HttpConfiguration()));
|
||||
connector.getQuicConfiguration().setPemWorkDirectory(workDir.getEmptyPathDir());
|
||||
server.addConnector(connector);
|
||||
assertThrows(IllegalStateException.class, server::start);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartHTTP3ServerConnectorWithValidKeyStoreInstanceWithoutPemWorkDir() throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
try (InputStream is = getClass().getResourceAsStream("/keystore.p12"))
|
||||
{
|
||||
keyStore.load(is, "storepwd".toCharArray());
|
||||
}
|
||||
sslContextFactory.setKeyStore(keyStore);
|
||||
sslContextFactory.setKeyManagerPassword("storepwd");
|
||||
HTTP3ServerConnector connector = new HTTP3ServerConnector(server, sslContextFactory, new HTTP3ServerConnectionFactory(new HttpConfiguration()));
|
||||
server.addConnector(connector);
|
||||
assertThrows(IllegalStateException.class, server::start);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartHTTP3ServerConnectorWithValidKeyStoreInstance() throws Exception
|
||||
{
|
||||
Server server = new Server();
|
||||
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
try (InputStream is = getClass().getResourceAsStream("/keystore.p12"))
|
||||
{
|
||||
keyStore.load(is, "storepwd".toCharArray());
|
||||
}
|
||||
sslContextFactory.setKeyStore(keyStore);
|
||||
sslContextFactory.setKeyManagerPassword("storepwd");
|
||||
HTTP3ServerConnector connector = new HTTP3ServerConnector(server, sslContextFactory, new HTTP3ServerConnectionFactory(new HttpConfiguration()));
|
||||
connector.getQuicConfiguration().setPemWorkDirectory(workDir.getEmptyPathDir());
|
||||
server.addConnector(connector);
|
||||
try
|
||||
{
|
||||
server.start();
|
||||
}
|
||||
finally
|
||||
{
|
||||
LifeCycle.stop(server);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -161,7 +161,7 @@ public class QuicServerConnector extends AbstractNetworkConnector
|
|||
|
||||
Set<String> aliases = sslContextFactory.getAliases();
|
||||
if (aliases.isEmpty())
|
||||
throw new IllegalStateException("Invalid KeyStore: no aliases");
|
||||
throw new IllegalStateException("Missing or invalid KeyStore: a SslContextFactory configured with a valid, non-empty KeyStore is required");
|
||||
String alias = sslContextFactory.getCertAlias();
|
||||
if (alias == null)
|
||||
alias = aliases.stream().findFirst().orElseThrow();
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -200,7 +200,7 @@
|
|||
<!-- but hey we have no more strange people?? :P -->
|
||||
<infinispan.docker.image.version>11.0.14.Final</infinispan.docker.image.version>
|
||||
<infinispan.protostream.version>4.6.5.Final</infinispan.protostream.version>
|
||||
<infinispan.version>11.0.17.Final</infinispan.version>
|
||||
<infinispan.version>11.0.18.Final</infinispan.version>
|
||||
<injection.bundle.version>1.2</injection.bundle.version>
|
||||
|
||||
<!-- testing -->
|
||||
|
@ -345,7 +345,7 @@
|
|||
<swissbox.version>1.8.3</swissbox.version>
|
||||
<taglibs-standard-impl.version>1.2.5</taglibs-standard-impl.version>
|
||||
<taglibs-standard-spec.version>1.2.5</taglibs-standard-spec.version>
|
||||
<testcontainers.version>1.19.0</testcontainers.version>
|
||||
<testcontainers.version>1.19.1</testcontainers.version>
|
||||
<tinybundles.version>3.0.0</tinybundles.version>
|
||||
<versions.maven.plugin.version>2.14.2</versions.maven.plugin.version>
|
||||
<wildfly.common.version>1.6.0.Final</wildfly.common.version>
|
||||
|
|
|
@ -1510,7 +1510,7 @@ public class DistributionTests extends AbstractJettyHomeTest
|
|||
int httpPort = distribution.freePort();
|
||||
try (JettyHomeTester.Run run2 = distribution.start(List.of("jetty.http.selectors=1", "jetty.http.port=" + httpPort)))
|
||||
{
|
||||
assertTrue(run2.awaitConsoleLogsFor("Started Server@", 10, TimeUnit.SECONDS));
|
||||
assertTrue(run2.awaitConsoleLogsFor("Started oejs.Server@", 10, TimeUnit.SECONDS));
|
||||
|
||||
startHttpClient();
|
||||
ContentResponse response = client.newRequest("localhost", httpPort)
|
||||
|
|
Loading…
Reference in New Issue