OpenSSL is a robust, open-source toolkit that implements the Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols, which are essential for secure communication over networks.
For developers working with secure connections, encryption, or digital certificates, installing and properly configuring OpenSSL libraries becomes a necessary skill.
Many developers encounter confusion when they try to build code that depends on OpenSSL. This often happens when they’ve installed the OpenSSL command-line tools but find themselves missing the development libraries needed for compilation.
When you install the basic OpenSSL package on Ubuntu using apt-get install openssl, you’re only getting the command-line tools and runtime libraries. This is intentional – package managers separate runtime components from development components to:
Ubuntu follows specific naming conventions for packages that are helpful to understand:
Learning these naming patterns makes finding the right packages much easier.
The simplest and most reliable way to install OpenSSL development libraries is through the package manager:
sudo apt-get install libssl-dev
This installs the header files and development libraries needed for compiling programs that use OpenSSL.
Read: How to install and uninstall applications on Ubuntu – A Beginner’s guide
If you’re not sure which package you need, Ubuntu provides several ways to search for packages:
# Search for packages containing “ssl”
apt-cache search ssl | grep dev
# Check which package provides a specific header file
apt-file search openssl/bio.h
The second command requires the apt-file tool, which you can install with sudo apt-get install apt-file followed by sudo apt-file update.
Read: Fix Broken Packages in Ubuntu 24.04: Step-by-Step Guide to Package Repair & Removal
Ubuntu’s bash supports helpful tab completion that can show available packages:
sudo apt-get install libssl-[TAB][TAB]
This will display all packages starting with “libssl-“, making it easier to find the right one.
While using package managers is preferred, sometimes you might need a specific version not available in the repositories. Here’s how to install OpenSSL from source:
sudo apt-get install build-essential checkinstall zlib1g-dev
Visit the OpenSSL website to find the version you need, then download it:
wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
Always verify the integrity of downloaded files:
wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz.sha256
sha256sum openssl-1.1.1g.tar.gz
cat openssl-1.1.1g.tar.gz.sha256
tar -xf openssl-1.1.1g.tar.gz
cd openssl-1.1.1g
./config –prefix=/usr/local/ssl –openssldir=/usr/local/ssl shared zlib
The shared option ensures that dynamic libraries are built, which is typically what you want for development.
make
sudo make install
Create a configuration file for the linker:
sudo bash -c ‘echo “/usr/local/ssl/lib” > /etc/ld.so.conf.d/openssl.conf’
sudo ldconfig
Add the new OpenSSL binary directory to your PATH:
echo ‘export PATH=”/usr/local/ssl/bin:$PATH”‘ >> ~/.bashrc
source ~/.bashrc
Read: How is the path environment variable managed in Linux/Ubuntu/Debian?
Check that the correct version is now available:
openssl version
Include the necessary headers in your source files:
When compiling programs that use OpenSSL:
g++ -o myprogram myprogram.cpp -lssl -lcrypto
If you’ve installed OpenSSL in a custom location, you’ll need to specify the include and library paths:
g++ -o myprogram myprogram.cpp -I/usr/local/ssl/include -L/usr/local/ssl/lib -lssl -lcrypto
For more complex projects, pkg-config provides a cleaner way to get compiler flags:
g++ -o myprogram myprogram.cpp $(pkg-config –cflags –libs openssl)
If you see errors like openssl/bio.h: No such file or directory, you need to install the development package (libssl-dev).
If you get errors like undefined reference to ‘BIO_new’, ensure you’re linking with the correct libraries using -lssl -lcrypto.
If your code requires a specific OpenSSL version that differs from what’s provided by your distribution, consider installing from source or using container technologies to isolate your development environment.
If you have multiple OpenSSL installations, use the following to ensure you’re using the correct one:
which openssl
openssl version
echo $LD_LIBRARY_PATH
The distinction between runtime and development packages can be confusing. Here’s a clear breakdown:
Package naming conventions can vary between Linux distributions:
This is important to know if you’re working across different environments or writing documentation for multiple platforms.
Security vulnerabilities in cryptographic libraries like OpenSSL can have serious implications. Always:
Development files (headers, static libraries) are separated to reduce disk usage and simplify dependency management for end-users who don’t need to compile software.
Use the command openssl version to check the version of the OpenSSL command-line tool.
Yes, but it requires careful configuration of include paths, library paths, and environment variables to ensure each application uses the intended version.
-lssl links against the SSL/TLS implementation, while -lcrypto links against the cryptographic functions. Most applications using OpenSSL need both.
When upgrading OpenSSL, test your applications thoroughly before deploying to production. Consider using compatibility layers or containerization if breaking changes occur.
LibreSSL is a fork of OpenSSL created by the OpenBSD team with a focus on simplicity and security. It maintains API compatibility but has different development goals.
Use tools like openssl s_client and online security scanners to test your SSL/TLS configuration. Stay informed about security advisories and apply patches promptly.
The post How to Install OpenSSL Libraries on Ubuntu appeared first on net2.
It’s hard to believe that the first KubeCon took place nearly 10 years ago. Back…
Welcome to the first quarterly roundup on the State of Silicon and Devices by Canonical. …
Organizations are racing to harness the transformative power of AI, but sensitive data privacy and…
In this article, we will see how to install a specific version of llvm on…
The Ubuntu team is pleased to announce the Beta release of the Ubuntu 25.04 Desktop,…
The latest report from the International Data Corporation (IDC) co-sponsored by Canonical and Google Cloud…