Error while loading shared libraries: libssl.so.10: cannot open shared object file in Docker

16,961

Solution 1

I had a similar error when I installed RStudio on Ubuntu 19.10. It complained not finding libssl.so.1.0.0 and libcrypto.so.1.0.0. After sometime, I tried to locate if these files where installed on my system as trying to install them manually never worked. I used the locate command like so: locate libssl

This image shows the output of the locate command

The output showed that the 'missing' libraries were actually installed on my system. Then I tried to look in the lib (that is /lib/ directory) folder but never found these files. So I tried to copy them inferring their paths from the output of the locate command into the /lib/ directory as follows:

$sudo cp /snap/core/7917/lib/x86_64-linux-gnu/libssl.so.1.0.0 /lib/

I did the same for the libcrypto.so.1.0.0 lib file.

Then I tried to run RStudio again and it worked.

I hope this helps you. But be careful that you don't overwrite any files, otherwise you may end up with an unstable system.

Solution 2

The failure mode suggests that your libssl.so.10 is a broken symlink. Meaning the file libssl.so.1.0.0 does not exist.

A command such as ln -s libssl.so.1.0.0 libssl.so.10 will succeed even if the target of the symlink does not (yet) exist. Plain ls on the broken symlinks will not report anything untoward either.

If you want to be sure the symlinks are not broken, check each symlink with test -e.

More specifically using ln -s libssl.so.1.0.0 libssl.so.10 as some kind of 'fix' indicates you have other issues: the version component of a soname consists of abi-version.patch-level.backwards-compatibility fields and this is used by the loader to determine whether or not a given library file (symlinked or otherwise) could possibly match the library requested by the application. As you can see, using ln you are claiming that ABI version 1 is the same as ABI version 10. That may not work as expected.

Finally, your ln commands use relative paths so you are probably working in the wrong directory -- hence why you end up creating broken symlinks. On Debian based systems libssl.so can typically be found in /usr/lib/x86_64-linux-gnu/. The x86_64-linux-gnu bit depends on architecture (as defined by Debian multi arch support), this particular example is valid for 64 bit x86 code.

Share:
16,961
user1578872
Author by

user1578872

Updated on June 04, 2022

Comments

  • user1578872
    user1578872 almost 2 years

    I am trying to build an image with stunnel.

    My base image OS is,

    Linux 2338b11efbe1 4.9.93-linuxkit-aufs #1 SMP Wed Jun 6 16:55:56 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

    Installing libssl as below.

    RUN apt-get -y update
    RUN apt-get -y install libssl1.0.0 libssl-dev && \
        ln -s libssl.so.1.0.0 libssl.so.10 && \
        ln -s libcrypto.so.1.0.0 libcrypto.so.10
    

    Below command lists the libs.

    RUN ls libssl.so.* libcrypto.so*

    Output ------>>>

    libcrypto.so.10
    libssl.so.10
    

    Still, below command fails.

    RUN ./stunnel

    Error :-

    ./stunnel: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory

    Am i missing any other instruction here.

    Here is my complete dockerfile.

    from <BASE_IMAGE>
    COPY stunnel .
    ENV DEBIAN_FRONTEND noninteractive
    RUN apt-get -y update && \
        apt-get -y install libssl1.0.0 libssl-dev && \
        ln -s libssl.so.1.0.0 libssl.so.10 && \
        ln -s libcrypto.so.1.0.0 libcrypto.so.10
    RUN ./stunnel
    
    • BMitch
      BMitch about 5 years
      Can you provide a minimal reproducible example rather than a few of the commands? A complete Dockerfile that doesn't depend on other unshared files to ADD and COPY in would allow us to reproduce this.
    • jww
      jww about 5 years
      Is stunnel built against OpenSSL 1.1.0 or 1.0.2? They are not binary compatible, and you must have the correct one installed on the system. Also see How does the versioning scheme work? in the OpenSSL FAQ.
    • user1578872
      user1578872 about 5 years
      @jww - When i ran stunnel, it was looking for libssl.so.10. I believe it is using libssl/so.1.0.0. My stunnel verison is 5.40.
    • user1578872
      user1578872 about 5 years
      @BMitch - I have updated the dockerfile.
    • BMitch
      BMitch about 5 years
      @user1578872 that unfortunately won't build for me. I don't have that base image, and the next copy command will fail without a stunnel binary that I don't know how you created/downloaded.
  • user1578872
    user1578872 about 5 years
    I have the following libs under /usr/x86_64-linux-gnu/ 1.libssl.a 2.libssl.so 3.libssl.so.0.9.8 4.libssl3.so. Why it is not picking the exsting lib?