Merge remote-tracking branch 'origin/jetty-10.0.x' into jetty-11.0.x
This commit is contained in:
commit
38a57e16e5
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,7 +13,7 @@
|
|||
<properties>
|
||||
<bundle-symbolic-name>${project.groupId}.jaas</bundle-symbolic-name>
|
||||
<apacheds.version>2.0.0.AM26</apacheds.version>
|
||||
<apache.directory.api.version>2.1.4</apache.directory.api.version>
|
||||
<apache.directory.api.version>2.1.5</apache.directory.api.version>
|
||||
<spotbugs.onlyAnalyze>org.eclipse.jetty.jaas.*</spotbugs.onlyAnalyze>
|
||||
</properties>
|
||||
|
||||
|
|
|
@ -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
|
@ -53,7 +53,7 @@
|
|||
<hawtio.version>2.15.2</hawtio.version>
|
||||
<hazelcast.version>5.2.1</hazelcast.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>
|
||||
<jackson.version>2.14.2</jackson.version>
|
||||
<jakarta.activation.api.version>2.0.1</jakarta.activation.api.version>
|
||||
<jakarta.annotation.api.version>2.1.1</jakarta.annotation.api.version>
|
||||
|
@ -120,7 +120,7 @@
|
|||
<springboot.version>2.1.1.RELEASE</springboot.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>
|
||||
<weld.version>4.0.3.Final</weld.version>
|
||||
<wildfly.common.version>1.6.0.Final</wildfly.common.version>
|
||||
<wildfly.elytron.version>2.2.2.Final</wildfly.elytron.version>
|
||||
|
|
Loading…
Reference in New Issue