diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/AbstractHTTP2ServerConnectionFactory.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/AbstractHTTP2ServerConnectionFactory.java index 0a5b1f85281..dca0334d49c 100644 --- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/AbstractHTTP2ServerConnectionFactory.java +++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/AbstractHTTP2ServerConnectionFactory.java @@ -53,12 +53,15 @@ public abstract class AbstractHTTP2ServerConnectionFactory extends AbstractConne public AbstractHTTP2ServerConnectionFactory(@Name("config") HttpConfiguration httpConfiguration) { - this(httpConfiguration,"h2","h2-17","h2-16","h2-15","h2-14"); + this(httpConfiguration,"h2"); } protected AbstractHTTP2ServerConnectionFactory(@Name("config") HttpConfiguration httpConfiguration, String... protocols) { super(protocols); + for (String p:protocols) + if (!HTTP2ServerConnection.isSupportedProtocol(p)) + throw new IllegalArgumentException("Unsupported HTTP2 Protocol variant: "+p); this.httpConfiguration = Objects.requireNonNull(httpConfiguration); addBean(httpConfiguration); } diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2CServerConnectionFactory.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2CServerConnectionFactory.java index 874e4ea360b..676ce9b88fd 100644 --- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2CServerConnectionFactory.java +++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2CServerConnectionFactory.java @@ -51,7 +51,15 @@ public class HTTP2CServerConnectionFactory extends HTTP2ServerConnectionFactory public HTTP2CServerConnectionFactory(@Name("config") HttpConfiguration httpConfiguration) { - super(httpConfiguration,"h2c","h2c-17","h2c-16","h2c-15","h2c-14"); + this(httpConfiguration,"h2c"); + } + + public HTTP2CServerConnectionFactory(@Name("config") HttpConfiguration httpConfiguration, String... protocols) + { + super(httpConfiguration,protocols); + for (String p:protocols) + if (!HTTP2ServerConnection.isSupportedProtocol(p)) + throw new IllegalArgumentException("Unsupported HTTP2 Protocol variant: "+p); } @Override diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnection.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnection.java index a2429a12919..a7e745fb537 100644 --- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnection.java +++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnection.java @@ -58,6 +58,31 @@ import org.eclipse.jetty.util.thread.ExecutionStrategy; public class HTTP2ServerConnection extends HTTP2Connection implements Connection.UpgradeTo { + + /** + * @param protocol A HTTP2 protocol variant + * @return True if the protocol version is supported + */ + public static boolean isSupportedProtocol(String protocol) + { + switch(protocol) + { + case "h2": + case "h2-17": + case "h2-16": + case "h2-15": + case "h2-14": + case "h2c": + case "h2c-17": + case "h2c-16": + case "h2c-15": + case "h2c-14": + return true; + default: + return false; + } + } + private final Queue channels = new ConcurrentArrayQueue<>(); private final ServerSessionListener listener; private final HttpConfiguration httpConfig; diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnectionFactory.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnectionFactory.java index 301431c9980..e69ef2efaa8 100644 --- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnectionFactory.java +++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HTTP2ServerConnectionFactory.java @@ -64,8 +64,7 @@ public class HTTP2ServerConnectionFactory extends AbstractHTTP2ServerConnectionF @Override public boolean isAcceptable(String protocol, String tlsProtocol, String tlsCipher) { - // TODO remove this draft 14 protection - // Implement 9.2.2 + // Implement 9.2.2 for draft 14 boolean acceptable = "h2-14".equals(protocol) || !(HTTP2Cipher.isBlackListProtocol(tlsProtocol) && HTTP2Cipher.isBlackListCipher(tlsCipher)); if (LOG.isDebugEnabled()) LOG.debug("proto={} tls={} cipher={} 9.2.2-acceptable={}",protocol,tlsProtocol,tlsCipher,acceptable);