How to Install the latest OpenSSL version from Source on Linux (oK)
How to Install the latest OpenSSL version from Source on Linux
On this page
OpenSSL is a widely used crypto library that implements SSL and TLS protocols for secure communication over computer networks. OpenSSL is used by many programs like Apache Web server, PHP, Postfix and many others. OpenSSL provides support for various cryptographic algorithms such as ciphers (AES, Blowfish, DES, IDEA etc.), cryptographic hash functions (MD5, MD4, SHA-1, SHA-2 etc.) and public key cryptography (RSA, DSA, Diffie-Hellman key exchange).
In this tutorial, I will show you step by step how to install the latest stable OpenSSL version from source on Ubuntu 18.04 and CentOS 7.6 servers.
What we will do?
Install Dependencies
Download OpenSSL Source Code
Install OpenSSL
Compile and Install OpenSSL
Configure Link Libraries
Configure OpenSSL Binary
Testing
Step 1 - Install Dependencies
The first step, before we can compile the OpenSSL library from source, is to install some package dependencies including the 'build-essential' package on Ubuntu, or 'Development Tools' package on CentOS.
On Ubuntu
Update the Ubuntu repository and install package dependencies for software compilation using the apt command below.
On CentOS
Install the 'Development Tools' and some packages libraries using the yum command.
After the installation is complete, go to the next step.
Step 2 - Download OpenSSL
In this tutorial, we will install the latest stable version of OpenSSL - OpenSSL 1.0.2o. You can download the source code from the OpenSSL site.
Go to the '/usr/local/src' directory and download the OpenSSL source code using wget.
Now extract the openssl.tar.gz file, and go to the 'openssl' directory.
The OpenSSL source code has been downloaded.
Step 3 - Install OpenSSL
Before installing the custom OpenSSL version to the system, let's check the installed version using the command below.
Below is my results on Ubuntu:
And this is on CentOS:
We will replace the '1.1.0g' version with the latest stable version 1.0.2o.
We will install the new OpenSSL version to the specific directory '/usr/local/ssl', and then enable the Link Libraries of OpenSSL, and configure the new binary PATH for OpenSSL.
Install and Compile OpenSSL
Go to the openssl downloaded directory '/usr/local/src/openssl'.
Configure and compile OpenSSL with commands below.
Wait for the OpenSSL compile process.
Note:
--prefix and --openssldir = Set the output path of the OpenSSL.
shared = force to create a shared library.
zlib = enable the compression using zlib library.
When the compile process is complete, install the OpenSSL using the command below.
OpenSSL is installed in the '/usr/local/ssl' directory.
Configure Link Libraries
Next, we will configure the shared libraries for OpenSSL. The new OpenSSL binary will load library files from the '/usr/local/ssl/lib' directory.
Go to the '/etc/ld.so.conf.d' directory and create new configuration file 'openssl-1.0.2o.conf'.
Paste the openssl library path directory.
Save and exit.
Now reload the dynamic link using the command below.
And you will see the OpenSSL libraries on the '/usr/local/ssl/lib' directory has been loaded.
Ubuntu:
CentOS:
Configure OpenSSL Binary
We will replace the default openssl binary '/usr/bin/openssl or /bin/openssl' with the new version '/usr/local/ssl/bin/openssl'.
On Ubuntu 18.04 LTS
Backup the binary files.
Edit the '/etc/environment' file using vim.
Now add the new OpenSSL binary directory as below
Save and exit.
Reload the environment file and test the new updated binary PATH.
Now check again the OpenSSL binary file.
You will get the result as below.
The binary path of OpenSSL for Ubuntu has been updated.
On CentOS 7.6
Backup the CentOS OpenSSL binary files.
Create new environment files for OpenSSL.
Paste configuration below.
Save and exit.
Make the openssl.sh file executable.
Load the OpenSSL environment and check the PATH bin directory using commands below.
Now check the OpenSSL file.
You will get the result as below.
The binary path for OpenSSL on CentOS has been updated.
Step 4 - Testing
Test the OpenSSL new version using the following command.
The result on Ubuntu.
Result on CentOS.
The new latest stable version of OpenSSL has been installed from source on Linux Ubuntu 18.04 and CentOS 7.5.
Last updated