error while loading shared libraries: libssl.so.1.1 (and libcrypto.so.1.1)

Solved.

Problem is that if you install non-Ubuntu version of openssl (unpatched) you get the "error while loading shared libraries" error, because this is something that was added by Ubuntu devs to their distribution (and I still don't know why and makes no sense and makes lots of trouble). Source: https://askubuntu.com/a/830532/676863

So, mostly you will run into this if you compiled an official version from https://www.openssl.org/source/ e.g. the openssl-1.0.2m.tar.gz version. While official Ubuntu patched (million times according to the guys at #ubuntu on Freenode) version is still openssl-1.0.2g and is the one you want to patch, compile and install to make it working.

Solution (edited from https://stackoverflow.com/a/22634441/3108268):

  1. I used this build https://launchpad.net/ubuntu/+source/openssl/1.0.2g-1ubuntu13 because it was most up-to-date.
  2. wget https://launchpad.net/ubuntu/+archive/primary/+files/openssl_1.0.2g.orig.tar.gz (might need to add --no-check-certificate)
  3. tar -xvf openssl_1.0.2g.orig.tar.gz
  4. wget https://launchpad.net/ubuntu/+archive/primary/+files/openssl_1.0.2g-1ubuntu13.debian.tar.xz
  5. tar -xvf openssl_1.0.2g-1ubuntu13.debian.tar.xz and mv debian openssl_1.0.2g-1ubuntu13
  6. whereis openssl locate current openssl and delete/remove/backup it.
  7. cd openssl_1.0.2g/ and patch -p1 < ../openssl_1.0.2g-1ubuntu13/patches/version-script.patch
  8. make clean and ./config shared --prefix=/usr/local --openssldir=/usr/local/ssl -Wl,--enable-new-dtags,-rpath,'$(LIBRPATH)' (or maybe you just need plain .config, doesn't work for me)
  9. make and make test and make install
  10. openssl version

I also needed to reboot to be able to connect back in via SSH. All these commands were executed via web console on a cloud server. Downloaded file directory names might be different, I didn't check, so do ls -l.