In this guide, we are going to install the latest version of OpenSSL on Ubuntu 16.04/18.04.

Ubuntu 20.04 comes with Openssl 1.1.1f which has a bug in it.  Upgrade to 1.1.1g is recommended

sudo apt-get update && sudo apt-get upgrade
openssl version -a

Download

sudo apt install build-essential checkinstall zlib1g-dev -y

cd /usr/local/src/
sudo wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
sudo tar -xf openssl-1.1.1g.tar.gz
cd openssl-1.1.1g

Install OpenSSL

sudo ./config –prefix=/usr/local/ssl –openssldir=/usr/local/ssl shared zlib
sudo make
sudo make test
sudo make install

Configured OpenSSL Shared Libaries

cd /etc/ld.so.conf.d/
sudo nano openssl-1.1.1g.conf
type /usr/local/ssl/lib

sudo ldconfig -v
sudo mv /usr/bin/c_rehash /usr/bin/c_rehash.backup
sudo mv /usr/bin/openssl /usr/bin/openssl.backup

sudo nano /etc/environment
type :/usr/local/ssl/bin” at the end

source /etc/environment
echo $PATH

which openssl
openssl version -a