Skip to content

Ensure we support ALPN when using java 8u251 - #10196

Merged
normanmaurer merged 6 commits into
4.1from
alpn_java8
Apr 21, 2020
Merged

normanmaurer merged 6 commits into
4.1from
alpn_java8

Conversation

@normanmaurer

Copy link
Copy Markdown
Member

Motivation:

ALPN support was backported to java 8 lately. Ensure we support it if the user uses the latest java 8 release

Modifications:

  • Update logic to be able to detect if ALPN is supported out of the box when using Java8
  • Update jetty alpn version

Result:

Be able to use ALPN out of the box when using java 8u251

Motivation:

ALPN support was backported to java 8 lately. Ensure we support it if the user uses the latest java 8 release

Modifications:

- Update logic to be able to detect if ALPN is supported out of the box when using Java8
- Update jetty alpn version

Result:

Be able to use ALPN out of the box when using java 8u251
@normanmaurer

Copy link
Copy Markdown
Member Author

@cescoffier PTAL

@cescoffier

Copy link
Copy Markdown

@normanmaurer Thanks! LGTM! Going to do a quick check with Quarkus.

@normanmaurer

Copy link
Copy Markdown
Member Author

@cescoffier thanks... let me know how it goes...

@normanmaurer

Copy link
Copy Markdown
Member Author

@slandelle PTAL again

@slandelle

Copy link
Copy Markdown
Contributor

LGTM

@normanmaurer

Copy link
Copy Markdown
Member Author

@cescoffier any update ? I am thinking about pulling this in and release a new version tomorrow if all works :)

@cescoffier

Copy link
Copy Markdown

@normanmaurer Unfortunately, not much, it seems that we need to integrate it in Vert.x first (at the moment Quarkus does not start with the version built from the PR (on Java 8, but does on Java 11)).

@normanmaurer

Copy link
Copy Markdown
Member Author

@cescoffier can you give me some idea why you need to do any changes in Vert.x first ?

@cescoffier

Copy link
Copy Markdown

@normanmaurer so-called hamburger architecture:

Quarkus is based on Vert.x which is based on Netty.

I've forced the Netty version in Quarkus, but tests are not passing. So, my guess is that we would need to check if Vert.x works with this version.

@normanmaurer

Copy link
Copy Markdown
Member Author

@cescoffier ok... please let me know once you tested vert.x

@cescoffier

Copy link
Copy Markdown

@vietj is on it.

@vietj

vietj commented Apr 21, 2020

Copy link
Copy Markdown
Contributor

@normanmaurer I will check on vertx side how it works with various combination of JDK

@vietj

vietj commented Apr 21, 2020

Copy link
Copy Markdown
Contributor

@normanmaurer

I tested with:

  • Java 11 (not the latest)
  • OpenJDK 1.8.0_252 (latest) with OOTB ALPN support
  • Oracle JDK 1.8.0_251 (latest) with OOTB ALPN support
  • Oracle JDK 1.8.0_192 with no ALPN support

and the following combinations of SSL:

  • JDK SSL
  • JDK SSL with ALPN agent
  • Boring SSL

It looks to work as expected in all cases target cases but has odd behaviour in two cases with the Jetty ALPN Agent 2.0.10.

On java version "1.8.0_181" (Oracle) + Jetty ALPN Agent we can spot this error in the log (SSL still works):

[main] ERROR io.netty.handler.ssl.JdkAlpnSslUtils - Unable to initialize JdkAlpnSslUtils, but the detected java version was: 8
java.security.PrivilegedActionException: java.lang.NoSuchMethodException: javax.net.ssl.SSLEngine.getHandshakeApplicationProtocol()
	at java.security.AccessController.doPrivileged(Native Method)
	at io.netty.handler.ssl.JdkAlpnSslUtils.<clinit>(JdkAlpnSslUtils.java:54)
	at io.netty.handler.ssl.JdkAlpnApplicationProtocolNegotiator.<clinit>(JdkAlpnApplicationProtocolNegotiator.java:30)
	at io.netty.handler.ssl.JdkSslContext.toNegotiator(JdkSslContext.java:399)
	at io.netty.handler.ssl.JdkSslClientContext.<init>(JdkSslClientContext.java:275)
	at io.netty.handler.ssl.SslContext.newClientContextInternal(SslContext.java:821)
	at io.netty.handler.ssl.SslContextBuilder.build(SslContextBuilder.java:576)
	at io.vertx.core.net.impl.SSLHelper.createContext(SSLHelper.java:294)
	at io.vertx.core.net.impl.SSLHelper.getContext(SSLHelper.java:478)
	at io.vertx.core.net.impl.SSLHelper.validate(SSLHelper.java:503)
	at io.vertx.core.http.impl.HttpClientImpl.<init>(HttpClientImpl.java:133)
	at io.vertx.core.impl.VertxImpl.createHttpClient(VertxImpl.java:319)
	at io.vertx.core.http.Http2TLSTest.createHttpClient(Http2TLSTest.java:29)
	at io.vertx.core.http.HttpTLSTest$TLSTest.run(HttpTLSTest.java:1123)
	at io.vertx.core.http.HttpTLSTest$TLSTest.pass(HttpTLSTest.java:1070)
	at io.vertx.core.http.HttpTLSTest.testTLSClientCertRequiredPKCS12(HttpTLSTest.java:220)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
	at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
	at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Caused by: java.lang.NoSuchMethodException: javax.net.ssl.SSLEngine.getHandshakeApplicationProtocol()
	at java.lang.Class.getMethod(Class.java:1786)
	at io.netty.handler.ssl.JdkAlpnSslUtils$1.run(JdkAlpnSslUtils.java:57)
	at io.netty.handler.ssl.JdkAlpnSslUtils$1.run(JdkAlpnSslUtils.java:54)
	... 45 more

On java1.8.0_251 (Oracle with ALPN support) + Jetty ALPN Agent we get this error which prevent SSL to work (however this works fine with OpenJDK 1.8.0_252)

Caused by: java.lang.NoSuchFieldError: nullSession
	at sun.security.ssl.ClientHandshaker.getKickstartMessage(ClientHandshaker.java:1350)
	at sun.security.ssl.Handshaker.kickstart(Handshaker.java:1117)
	at sun.security.ssl.SSLEngineImpl.kickstartHandshake(SSLEngineImpl.java:735)
	at sun.security.ssl.SSLEngineImpl.beginHandshake(SSLEngineImpl.java:757)
	at io.netty.handler.ssl.JdkSslEngine.beginHandshake(JdkSslEngine.java:158)
	at io.netty.handler.ssl.SslHandler.handshake(SslHandler.java:2030)

@normanmaurer

Copy link
Copy Markdown
Member Author

@vietj I fixed the logging problem... For the other issue I suspect you will need to talk with the jetty-alpn folks or you disagree ?

@vietj

vietj commented Apr 21, 2020

Copy link
Copy Markdown
Contributor

@normanmaurer I don't see the other as an issue to me, I'm just reporting my findings :-) however I will report it to Jetty ALPN project nevertheless

@normanmaurer

Copy link
Copy Markdown
Member Author

@vietj ok cool... I guess with this info this PR is ready to go... correct @vietj @cescoffier ?

@vietj

vietj commented Apr 21, 2020

Copy link
Copy Markdown
Contributor

@normanmaurer it looks to me but @cescoffier might want to do more tests

@cescoffier

cescoffier commented Apr 21, 2020 via email

Copy link
Copy Markdown

@normanmaurer

Copy link
Copy Markdown
Member Author

@cescoffier thanks a lot...

@cescoffier

Copy link
Copy Markdown

@normanmaurer Thanks to @vietj, we were able to test Quarkus and everything is ok!

@normanmaurer
normanmaurer merged commit 5cd00d2 into 4.1 Apr 21, 2020
@normanmaurer
normanmaurer deleted the alpn_java8 branch April 21, 2020 13:02
@normanmaurer

Copy link
Copy Markdown
Member Author

@cescoffier @vietj thanks a lot!

normanmaurer added a commit that referenced this pull request Apr 21, 2020
Motivation:

ALPN support was backported to java 8 lately. Ensure we support it if the user uses the latest java 8 release

Modifications:

- Update logic to be able to detect if ALPN is supported out of the box when using Java8
- Update jetty alpn version

Result:

Be able to use ALPN out of the box when using java 8u251
ihanyong pushed a commit to ihanyong/netty that referenced this pull request Jul 31, 2020
Motivation:

ALPN support was backported to java 8 lately. Ensure we support it if the user uses the latest java 8 release

Modifications:

- Update logic to be able to detect if ALPN is supported out of the box when using Java8
- Update jetty alpn version

Result:

Be able to use ALPN out of the box when using java 8u251
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants