netty / netty-tcnative

A fork of Apache Tomcat Native, based on finagle-native
Apache License 2.0
236 stars 179 forks source link

Compile openssl-dynamic against libssl-1.1 #518

Open kwart opened 4 years ago

kwart commented 4 years ago

The dynamically linked OpenSSL netty-tcnative doesn't work on Alpine Linux 3.9 and newer.

Linux netty-tcnative artifacts work fine for (our Hazelcast) Docker images based on Alpine Linux 3.8.

The problem is, Alpine 3.9 and newer updated the libssl in the system and only version 1.1 is available. The netty-tcnative doesn't work with this libssl version.

We are considering workaround (in hazelcast/hazelcast-docker#126) which would use openssl (and libssl) from Alpine 3.8, but it would be great to have it resolved in the openssl-dynamic module in the netty-tcnative. E.g. have both versions compiled and provide them either in different artifacts or use some kind of fallback.

docker run -it --rm alpine:3.11
apk add openssl apr
wget http://repo1.maven.org/maven2/io/netty/netty-tcnative/2.0.28.Final/netty-tcnative-2.0
.28.Final-linux-x86_64.jar
unzip netty-tcnative-2.0.28.Final-linux-x86_64.jar
ldd META-INF/native/libnetty_tcnative.so 
    /lib/ld-musl-x86_64.so.1 (0x7f6808474000)
Error loading shared library libssl.so.1.0.0: No such file or directory (needed by META-INF/native/libnetty_tcnative.so)
Error loading shared library libcrypto.so.1.0.0: No such file or directory (needed by META-INF/native/libnetty_tcnative.so)
    libapr-1.so.0 => /usr/lib/libapr-1.so.0 (0x7f6808221000)
    libpthread.so.0 => /lib/ld-musl-x86_64.so.1 (0x7f6808474000)
    libc.so.6 => /lib/ld-musl-x86_64.so.1 (0x7f6808474000)
    libuuid.so.1 => /lib/libuuid.so.1 (0x7f6808218000)
Error relocating META-INF/native/libnetty_tcnative.so: i2d_X509_NAME: symbol not found
Error relocating META-INF/native/libnetty_tcnative.so: TLSv1_1_method: symbol not found
[...cut...]

find / -name libssl*
/usr/lib/libssl.so.1.1
/lib/libssl.so.1.1

apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.8/main/ openssl=1.
0.2u-r0
ldd META-INF/native/libnetty_tcnative.so 
    /lib/ld-musl-x86_64.so.1 (0x7f8c0bfcf000)
    libssl.so.1.0.0 => /lib/libssl.so.1.0.0 (0x7f8c0bb48000)
    libcrypto.so.1.0.0 => /lib/libcrypto.so.1.0.0 (0x7f8c0b728000)
    libapr-1.so.0 => /usr/lib/libapr-1.so.0 (0x7f8c0b6f3000)
    libpthread.so.0 => /lib/ld-musl-x86_64.so.1 (0x7f8c0bfcf000)
    libc.so.6 => /lib/ld-musl-x86_64.so.1 (0x7f8c0bfcf000)
    libz.so.1 => /lib/libz.so.1 (0x7f8c0b6d9000)
    libuuid.so.1 => /lib/libuuid.so.1 (0x7f8c0b6d0000)
Error relocating META-INF/native/libnetty_tcnative.so: __strdup: symbol not found
Error relocating META-INF/native/libnetty_tcnative.so: __strndup: symbol not found

find / -name libssl*
/usr/lib/libssl.so.1.1
/usr/lib/libssl.so.1.0.0
/lib/libssl.so.1.1
/lib/libssl.so.1.0.0
kwart commented 4 years ago

We hit the same problem with the new OpenSSL version in official Red Hat OpenShift base images:

FROM registry.access.redhat.com/ubi8/ubi

Stacktrace:

Exception in thread "main" java.lang.UnsatisfiedLinkError: failed to load the required native library
        at io.netty.handler.ssl.OpenSsl.ensureAvailability(OpenSsl.java:432)
        at com.hazelcast.nio.ssl.OpenSSLEngineFactory.init(OpenSSLEngineFactory.java:78)
        at com.hazelcast.internal.nio.ssl.AbstractTLSChannelInitializer.loadSSLEngineFactory(AbstractTLSChannelInitializer.java:62)
        at com.hazelcast.internal.nio.ssl.AbstractTLSChannelInitializer.<init>(AbstractTLSChannelInitializer.java:39)
        at com.hazelcast.internal.nio.ssl.UnifiedTLSChannelInitializer.<init>(UnifiedTLSChannelInitializer.java:51)
        at com.hazelcast.internal.nio.EnterpriseChannelInitializerProvider.createUnifiedTlsChannelInitializer(EnterpriseChannelInitializerProvider.java:94)
        at com.hazelcast.internal.nio.EnterpriseChannelInitializerProvider.<init>(EnterpriseChannelInitializerProvider.java:37)
        at com.hazelcast.instance.impl.EnterpriseNodeExtension.createChannelInitializerProvider(EnterpriseNodeExtension.java:685)
        at com.hazelcast.instance.impl.DefaultNodeContext.createNetworkingService(DefaultNodeContext.java:157)
        at com.hazelcast.instance.impl.Node.<init>(Node.java:255)
        at com.hazelcast.instance.impl.HazelcastInstanceImpl.createNode(HazelcastInstanceImpl.java:147)
        at com.hazelcast.instance.impl.HazelcastInstanceImpl.<init>(HazelcastInstanceImpl.java:116)
        at com.hazelcast.instance.impl.HazelcastInstanceFactory.constructHazelcastInstance(HazelcastInstanceFactory.java:241)
        at com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:220)
        at com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:158)
        at com.hazelcast.core.Hazelcast.newHazelcastInstance(Hazelcast.java:91)
        at com.hazelcast.core.server.HazelcastMemberStarter.main(HazelcastMemberStarter.java:46)
Caused by: java.lang.IllegalArgumentException: Failed to load any of the given libraries: [netty_tcnative_linux_x86_64, netty_tcnative_linux_x86_64_fedora, netty_tcnative_x86_64, netty_tcnative]
        at io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:104)
        at io.netty.handler.ssl.OpenSsl.loadTcNative(OpenSsl.java:526)
        at io.netty.handler.ssl.OpenSsl.<clinit>(OpenSsl.java:93)
        ... 16 more
        Suppressed: java.lang.UnsatisfiedLinkError: could not load a native library: netty_tcnative_linux_x86_64
                at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:233)
                at io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:96)
                ... 18 more
        Caused by: java.io.FileNotFoundException: META-INF/native/libnetty_tcnative_linux_x86_64.so
                at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:173)
                ... 19 more
                Suppressed: java.lang.UnsatisfiedLinkError: no netty_tcnative_linux_x86_64 in java.library.path
                        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1871)
                        at java.lang.Runtime.loadLibrary0(Runtime.java:871)
                        at java.lang.System.loadLibrary(System.java:1124)
                        at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
                        at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:316)
                        at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:136)
                        ... 19 more
                        Suppressed: java.lang.UnsatisfiedLinkError: no netty_tcnative_linux_x86_64 in java.library.path
                                at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1871)
                                at java.lang.Runtime.loadLibrary0(Runtime.java:871)
                                at java.lang.System.loadLibrary(System.java:1124)
                                at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
                                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 io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:336)
                                at java.security.AccessController.doPrivileged(Native Method)
                                at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:328)
                                at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:306)
                                ... 20 more
        Suppressed: java.lang.UnsatisfiedLinkError: could not load a native library: netty_tcnative_linux_x86_64_fedora
                at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:233)
                at io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:96)
                ... 18 more
        Caused by: java.io.FileNotFoundException: META-INF/native/libnetty_tcnative_linux_x86_64_fedora.so
                at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:173)
                ... 19 more
                Suppressed: java.lang.UnsatisfiedLinkError: no netty_tcnative_linux_x86_64_fedora in java.library.path
                        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1871)
                        at java.lang.Runtime.loadLibrary0(Runtime.java:871)
                        at java.lang.System.loadLibrary(System.java:1124)
                        at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
                        at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:316)
                        at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:136)
                        ... 19 more
                        Suppressed: java.lang.UnsatisfiedLinkError: no netty_tcnative_linux_x86_64_fedora in java.library.path
                                at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1871)
                                at java.lang.Runtime.loadLibrary0(Runtime.java:871)
                                at java.lang.System.loadLibrary(System.java:1124)
                                at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
                                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 io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:336)
                                at java.security.AccessController.doPrivileged(Native Method)
                                at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:328)
                                at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:306)
                                ... 20 more
        Suppressed: java.lang.UnsatisfiedLinkError: could not load a native library: netty_tcnative_x86_64
                at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:233)
                at io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:96)
                ... 18 more
        Caused by: java.io.FileNotFoundException: META-INF/native/libnetty_tcnative_x86_64.so
                at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:173)
                ... 19 more
                Suppressed: java.lang.UnsatisfiedLinkError: no netty_tcnative_x86_64 in java.library.path
                        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1871)
                        at java.lang.Runtime.loadLibrary0(Runtime.java:871)
                        at java.lang.System.loadLibrary(System.java:1124)
                        at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
                        at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:316)
                        at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:136)
                        ... 19 more
                        Suppressed: java.lang.UnsatisfiedLinkError: no netty_tcnative_x86_64 in java.library.path
                                at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1871)
                                at java.lang.Runtime.loadLibrary0(Runtime.java:871)
                                at java.lang.System.loadLibrary(System.java:1124)
                                at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
                                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 io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:336)
                                at java.security.AccessController.doPrivileged(Native Method)
                                at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:328)
                                at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:306)
                                ... 20 more
        Suppressed: java.lang.UnsatisfiedLinkError: /tmp/libnetty_tcnative1862968541861883969.so: libssl.so.10: cannot open shared object file: No such file or directory
                at java.lang.ClassLoader$NativeLibrary.load(Native Method)
                at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1946)
                at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1828)
                at java.lang.Runtime.load0(Runtime.java:810)
                at java.lang.System.load(System.java:1088)
                at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:36)
                at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:316)
                at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:215)
                at io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:96)
                ... 18 more
                Suppressed: java.lang.UnsatisfiedLinkError: /tmp/libnetty_tcnative1862968541861883969.so: libssl.so.10: cannot open shared object file: No such file or directory
                        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
                        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1946)
                        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1828)
                        at java.lang.Runtime.load0(Runtime.java:810)
                        at java.lang.System.load(System.java:1088)
                        at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:36)
                        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 io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:336)
                        at java.security.AccessController.doPrivileged(Native Method)
                        at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:328)
                        at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:306)
                        ... 20 more
                Suppressed: java.lang.UnsatisfiedLinkError: no netty_tcnative in java.library.path
                        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1871)
                        at java.lang.Runtime.loadLibrary0(Runtime.java:871)
                        at java.lang.System.loadLibrary(System.java:1124)
                        at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
                        at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:316)
                        at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:136)
                        ... 19 more
                        Suppressed: java.lang.UnsatisfiedLinkError: no netty_tcnative in java.library.path
                                at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1871)
                                at java.lang.Runtime.loadLibrary0(Runtime.java:871)
                                at java.lang.System.loadLibrary(System.java:1124)
                                at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
                                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 io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:336)
                                at java.security.AccessController.doPrivileged(Native Method)
                                at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:328)
                                at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:306)
                                ... 20 more
shartte commented 3 years ago

This affects CentOS 8 / RHEL 8 as well, but can be solved by installing the package compat-openssl10. It would obviously be nicer if it "just worked" (tm) with OpenSSL 1.1 from the openssl-libs package.

semihbkgr commented 1 year ago

any progress or update on this issue?

hsomu commented 6 months ago

Any progress or update on the above issue?