question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use netty 4.1+ TLS with Android 6

See original GitHub issue

My project currently uses a modified version of 4.0.28.Final which runs on Android 6.0.1. The diff is basically removing all classes which are not existent on Android 6.0.1 to be able to compile netty as a shared library for our Android build. To use TLS with the parameters needed we construct the SSLEngine ourself and hand it over to the netty SslHandler(SSLEngine engine).

We wanted to upgrade netty to 4.1.28.Final which has better Android support and tons of fixes regarding TLS compared to version 4.0.28.Final. Since we are using Android 6.0.1 with Conscrypt/BoringSSL the constructed SSLEngine is a org.conscrypt.OpenSSLEngineImpl.

Expected behavior

When we init SslHandler() with org.conscrypt.OpenSSLEngineImpl we expect SslHandler to detect the given SSLEngine to be a SslEngineType.CONSCRYPT.

Actual behavior

SSLHandler will fallback to SslEngineType.JDK due to:

engineType = SslEngineType.forEngine(engine);

which calls

static SslEngineType forEngine(SSLEngine engine) {
    return engine instanceof ReferenceCountedOpenSslEngine ? TCNATIVE :
    engine instanceof ConscryptAlpnSslEngine ? CONSCRYPT : JDK;
}

I also noticed PlatformDependent0.javaVersion0() will set to

if (isAndroid0()) {
    majorVersion = 6;
} 

but Android 6.0.1 will provide Java 1.7.

Steps to reproduce

SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
sslContext.init(kmf.getKeyManagers(),tmf.getTrustManagers(), new SecureRandom());
SSLEngine sslEngine = sslContext.createSSLEngine();
sslEngine.setUseClientMode(true);
SslHandler sslHandler = new SslHandler(sslEngine);
channel.pipeline().addFirst(sslHandler)

Minimal yet complete reproducer code (or URL to code)

N.A.

Netty version

netty-4.1.28.Final

JVM version (e.g. java -version)

SDK API-level 23 Java 1.7

OS version (e.g. uname -a)

Linux localhost 4.4.111-1.1.1 #14 SMP PREEMPT Wed May 16 01:39:17 CEST 2018 armv7l

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
gnareacommented, Apr 10, 2020

See also #10181

1reaction
normanmaurercommented, Aug 17, 2018

@selop so I did some digging and I think the problem here is that Android uses a “different conscrypt” implementation than what we use here. So I think it is not really “that” easy. Can you tell me what problem you have because of the current implementation ? I think even with JDK it should “just work”.

/cc @nmittler @ejona86 @carl-mastrangelo

Read more comments on GitHub >

github_iconTop Results From Across the Web

Netty: Home
Netty is an asynchronous event-driven network application framework for rapid development of maintainable high performance protocol servers & clients.
Read more >
netty - ssl/tls two way authentication - Stack Overflow
I was facing this problem while performing two way SSL with Netty. I solved it by using following configuration:
Read more >
Authentication
This document provides code samples demonstrating how to provide SSL/TLS encryption support and identity assertions in Java, as well as passing OAuth2 tokens...
Read more >
AGP 7.1.1 Depends on Vulnerable Netty Version [220795136]
Unfortunately Netty prior to 4.1.71 has multiple documented CVEs ... 2.8.6 | | | +--- com.google.android:annotations:4.1.1.4 ...
Read more >
Dependency Versions - Spring
Group ID Artifact ID Version ch.qos.logback logback‑access 1.4.5 ch.qos.logback logback‑classic 1.4.5 ch.qos.logback logback‑core 1.4.5
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found