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.
This commit is contained in:
Norman Maurer 2019-04-17 08:16:55 +02:00 committed by GitHub
parent 1d9090aab2
commit 3ebd29f9c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -576,7 +576,10 @@ public abstract class ReferenceCountedOpenSslContext extends SslContext implemen
protected static X509TrustManager chooseTrustManager(TrustManager[] managers) { protected static X509TrustManager chooseTrustManager(TrustManager[] managers) {
for (TrustManager m : managers) { for (TrustManager m : managers) {
if (m instanceof X509TrustManager) { 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"); throw new IllegalStateException("no X509TrustManager found");