Ubuntu 22.04 Missing OpenSSL 1.1

Linux / Ubuntu is strange. I was doing my regular ruby dev work as usual, and openssl decided to disappear. Anything that wanted openssl 1.1 no longer worked. Whether that was ruby or python, it didn't matter. I know enough Linux to get work done, but not enough to know why things break at times.

I have encountered this issue a few times, and I figured I could help anyone (or my future self) who ran into this.

The problem I was seeing, was something like this:

~/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/openssl.rb:13:in `require': 
libssl.so.1.1: cannot open shared object file: No such file or directory -
 ~/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/x86_64-linux/openssl.so (LoadError)

After much googling, I found a tool called ldd . Running it gave me some results like this:

ldd ~/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/x86_64-linux/openssl.so
        linux-vdso.so.1 (0x00007ffcaa066000)
        libruby.so.3.2 => /home/nate/.asdf/installs/ruby/3.2.2/lib/libruby.so.3.2 (0x00007f1603a00000)
        libssl.so.1.1 => not found
        libcrypto.so.1.1 => not found
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1603e82000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1603200000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f1603e64000)
        libgmp.so.10 => /home/linuxbrew/.linuxbrew/opt/gmp/lib/libgmp.so.10 (0x00007f1602e00000)
        libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f16039c6000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f160407c000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f1603e5f000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1603e5a000)

So for god only knows what reason, libssl can no longer be found. I had a similar issue to this before, so I first tried what I did there:

ln -s /lib/x86_64-linux-gnu/libssl.so.3 /lib/x86_64-linux-gnu/libssl.so.1.1

But that didn't quite work. Anything using ssl would give me an openssl error. It was very close to what I get running ldd again.

ldd /home/nate/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/karafka-rdkafka-0.13.2/ext/librdkafka.so
/home/nate/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/karafka-rdkafka-0.13.2/ext/librdkafka.so: /lib/x86_64-linux-gnu/libcrypto.so.1.1: version `OPENSSL_1_1_0' not found (required by /home/nate/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/karafka-rdkafka-0.13.2/ext/librdkafka.so)
/home/nate/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/karafka-rdkafka-0.13.2/ext/librdkafka.so: /lib/x86_64-linux-gnu/libssl.so.1.1: version `OPENSSL_1_1_0' not found (required by /home/nate/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/karafka-rdkafka-0.13.2/ext/librdkafka.so)
        linux-vdso.so.1 (0x00007ffe82b2a000)
        liblz4.so.1 => /lib/x86_64-linux-gnu/liblz4.so.1 (0x00007fa24a158000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fa24a071000)
        libcurl.so.4 => /lib/x86_64-linux-gnu/libcurl.so.4 (0x00007fa249fca000)
        libzstd.so.1 => /lib/x86_64-linux-gnu/libzstd.so.1 (0x00007fa249efb000)
        libsasl2.so.3 => /lib/x86_64-linux-gnu/libsasl2.so.3 (0x00007fa249ee0000)
        libssl.so.1.1 => /lib/x86_64-linux-gnu/libssl.so.1.1 (0x00007fa249e3a000)
        libcrypto.so.1.1 => /lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007fa249800000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fa249e1e000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa249400000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fa24a37a000)
        libnghttp2.so.14 => /lib/x86_64-linux-gnu/libnghttp2.so.14 (0x00007fa249df4000)
        libidn2.so.0 => /lib/x86_64-linux-gnu/libidn2.so.0 (0x00007fa249dd3000)
        librtmp.so.1 => /lib/x86_64-linux-gnu/librtmp.so.1 (0x00007fa249db2000)
        libssh.so.4 => /lib/x86_64-linux-gnu/libssh.so.4 (0x00007fa249d45000)
        libpsl.so.5 => /lib/x86_64-linux-gnu/libpsl.so.5 (0x00007fa249d31000)
        libgssapi_krb5.so.2 => /lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007fa249cdd000)
        libldap-2.5.so.0 => /lib/x86_64-linux-gnu/libldap-2.5.so.0 (0x00007fa249c7e000)
        liblber-2.5.so.0 => /lib/x86_64-linux-gnu/liblber-2.5.so.0 (0x00007fa249c6d000)
        libbrotlidec.so.1 => /lib/x86_64-linux-gnu/libbrotlidec.so.1 (0x00007fa249c5d000)
        libunistring.so.2 => /lib/x86_64-linux-gnu/libunistring.so.2 (0x00007fa249656000)
        libgnutls.so.30 => /lib/x86_64-linux-gnu/libgnutls.so.30 (0x00007fa249215000)
        libhogweed.so.6 => /lib/x86_64-linux-gnu/libhogweed.so.6 (0x00007fa2491cd000)
        libnettle.so.8 => /lib/x86_64-linux-gnu/libnettle.so.8 (0x00007fa249187000)
        libgmp.so.10 => /lib/x86_64-linux-gnu/libgmp.so.10 (0x00007fa249105000)
        libkrb5.so.3 => /lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007fa24903a000)
        libk5crypto.so.3 => /lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007fa24900b000)
        libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007fa249c55000)
        libkrb5support.so.0 => /lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007fa249c47000)
        libbrotlicommon.so.1 => /lib/x86_64-linux-gnu/libbrotlicommon.so.1 (0x00007fa249633000)
        libp11-kit.so.0 => /lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007fa248ed0000)
        libtasn1.so.6 => /lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007fa248eb8000)
        libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007fa24962c000)
        libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007fa248ea4000)
        libffi.so.8 => /lib/x86_64-linux-gnu/libffi.so.8 (0x00007fa248e97000)

So that didn't work at all.

Bottom line. I did more google searching, and found a StackOverflow post that was the closest thing to the problem I had and I did what it said.

wget http://nz2.archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.19_amd64.deb

sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2.19_amd64.deb

If that doesnt work, find the link here.

And yay! That finally fixed the problem. Don't ask me how libssl went missing, I just know it did.