[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jetty-users] Jetty server with http2 and jdk9 and its ALPN implementation
|
Hi,
On Tue, Oct 3, 2017 at 5:59 PM, Jan Weinschenker
<Jan.Weinschenker@xxxxxxxxxxxxx> wrote:
> Hi all,
>
> I am using jetty 9.4.7.v20170914 to run a server that supports http2.
> Everything works fine with jdk8 and jetty’s alpn-boot implementation.
>
> My question is: is 9.4.7 capable to run an http2 server with jdk9 and jdk9’s
> implementation of ALPN?
Yes. https://webtide.com runs in that way (standalone server).
> How would I instantiate a jetty server that uses jdk9’s ALPN instead of
> jetty’s own ALPN implementation?
>
> currently, with jdk8, my jetty-http2-server is created this way:
> - complete code:
> https://github.com/janweinschenker/servlet4-demo/blob/master/spring-boot/src/main/java/de/holisticon/servlet4demospringboot/Application.java
>
> --------------------------------------------------
>
> // SSL Context Factory for HTTPS and HTTP/2
> SslContextFactory sslContextFactory = new SslContextFactory();
> sslContextFactory.setKeyStoreResource(newClassPathResource("sample.jks"));
> sslContextFactory.setKeyStorePassword("secret");
> sslContextFactory.setKeyManagerPassword("secret");
> sslContextFactory.setCipherComparator(HTTP2Cipher.COMPARATOR);
> sslContextFactory.setUseCipherSuitesOrder(true);
>
> // HTTPS Configuration
> HttpConfiguration httpsConfig = new HttpConfiguration(http11Config);
> httpsConfig.addCustomizer(new SecureRequestCustomizer());
>
> // HTTP/2 Connection Factory
> HTTP2ServerConnectionFactory h2 = new
> HTTP2ServerConnectionFactory(httpsConfig);
>
> NegotiatingServerConnectionFactory.checkProtocolNegotiationAvailable();
> ALPNServerConnectionFactory alpnServerConnectionFactory = new
> ALPNServerConnectionFactory();
> alpnServerConnectionFactory.setDefaultProtocol("h2");
> alpnServerConnectionFactory.getALPNProcessor();
>
> // SSL Connection Factory
> SslConnectionFactory sslConnectionFactory = new
> SslConnectionFactory(sslContextFactory,
> alpnServerConnectionFactory.getProtocol());
>
> // HTTP/2 Connector
> ServerConnector http2Connector =
> new ServerConnector(server, sslConnectionFactory,
> alpnServerConnectionFactory, h2, new HttpConnectionFactory(httpsConfig));
> http2Connector.setPort(8444);
>
> --------------------------------------------------
>
> I guess that I have to change the code around the instantiation of the
> ALPNServerConnectionFactory??
No, the code remains the same.
What you need to change is the classpath.
You don't need anymore alpn-boot in the bootclasspath, but you need:
* jetty-alpn-java-server-9.4.7.v20170914.jar
* alpn-api-1.1.3.v20160715.jar
in the classpath.
--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.