How to Build and Install OpenSSL from Source on Ubuntu Linux

OpenSSL Cryptography and SSL/TLS Toolkit is an open-source, full-featured package used in Transport Layer Security (TLS) and Secure Socket Layer (SSL) protocols to provide secure communication between client and server. This commercial-grade and robust toolkit is widely used by various programs like PHP, Internet servers, comprising the majority of HTTPS websites.

Most Linux distributions come pre-installed with the OpenSSL library. However, in some cases, the OpenSSL library is not there so you have to install it yourself.

To check if your Linux system has on it or not, run the following command:

This command will tell you the version of the OpenSSL library installed on your system. If the command doesn’t return you with a version number, this means the OpenSSL toolkit is missing, and you need to install it to use it.

In this tutorial, you will see how you can easily install the OpenSSL library with the help of a few simple steps.

This document assumes you hold basic knowledge of Linux and you have a little bit of practice of Linux terminal.

This tutorial is compatible with all recent Ubuntu versions incl. Ubuntu 22.04 and ubuntu 20.04.

Let’s get started!

Installation Guide:

Step 1: Update and Upgrade

Before installing any new application or tool, make a habit of running the update command as it updates the latest versions of the packages that are already there in your system.

To do that run the following command:

After updating the packages, you have to run the upgrade command for the new versions of the packages to be installed on your system. Apt Update only updates the packages, and apt upgrade installs them.

To upgrade, run the following command:

Also, run the following command to install the zlib1g-dev package. This package holds development support files.

Step 2: Source Code:

Next, go to the src directory following the path shown below where you will download OpenSSL tool’s source code to install it.

Follow these commands to download the code from its official page:

Step 3: Configuration:

Now that we have downloaded the OpenSSL toolkit, we will configure it in this step with the help of the following commands:

Step 4: Link the libraries

Now that the installation is all done, we will link the shared libraries so that they load at runtime without giving any errors.

To do that go to the directory as shown below:

Next, open the openssl-1.1.1k.conf configuration file with nano editor command like this:

Now paste the following path in the configuration file:

Next, reload the dynamic link with the following command:

Using nano editor, edit the /etc/environment file:

Add this line to the file. Then save and close it.

Step 5: Verify installation

To check OpenSSL installation and version, run the command below:

You can also run the following command to see if the OpenSSL toolkit has been successfully installed or not.

If it returns you with the OpenSSL version, this means your installation has been successful.

In this tutorial we saw, how to install the OpenSSL toolkit step by step and in detail. With the help of this toolkit, you will be able to generate private keys, create CSRs, generate and install your SSL/TLS certificate, identify certificate information, encrypt and decrypt data, verify checksums, and monitor secure web server connectivity with OpenSSL, and check for revoked website certificates.

Leave a Comment