From 3ebd29f9c7e99db5bc3319707379ded6c0f6fa7b Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Wed, 17 Apr 2019 08:16:55 +0200 Subject: [PATCH] Only try to use OpenSslX509TrustManagerWrapper when using Java 7+ (#9065) Motivation: We should only try to use OpenSslX509TrustManagerWrapper when using Java 7+ as otherwise it fail to init in it's static block as X509ExtendedTrustManager was only introduced in Java7 Modifications: Only call OpenSslX509TrustManagerWrapper if we use Java7+ Result: Fixes https://github.com/netty/netty/issues/9064. --- .../io/netty/handler/ssl/ReferenceCountedOpenSslContext.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslContext.java b/handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslContext.java index 8aef599b51..3c719780fa 100644 --- a/handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslContext.java +++ b/handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslContext.java @@ -576,7 +576,10 @@ public abstract class ReferenceCountedOpenSslContext extends SslContext implemen protected static X509TrustManager chooseTrustManager(TrustManager[] managers) { for (TrustManager m : managers) { if (m instanceof X509TrustManager) { - return OpenSslX509TrustManagerWrapper.wrapIfNeeded((X509TrustManager) m); + if (PlatformDependent.javaVersion() >= 7) { + return OpenSslX509TrustManagerWrapper.wrapIfNeeded((X509TrustManager) m); + } + return (X509TrustManager) m; } } throw new IllegalStateException("no X509TrustManager found");