Author:
OpenSSL, zlib, and cURL are open-source computer software projects to secure communications over computer networks, compress data, and transfer data through various network protocols, respectively. The projects are comprised of command-line tools, header files, and libraries. They are widely used by many systems, applications, and libraries including Refinitiv Real-Time SDK C/C++. Users can utilize OpenSSL, zlib, and cURL libraries available on the system or build the latest versions of those libraries from the source code.
Refinitiv Real-Time SDK C/C++ is a suite of modern and open-source APIs that is designed to simplify development through a strong focus on ease of use and standardized access to a broad set of Refinitiv and proprietary content and services. It uses these libraries to connect to encrypted servers or Refinitiv Real-Time Optimized on the cloud.
This article demonstrates step by step to build OpenSSL, zlib, and cURL libraries from the source code on a Linux machine (Centos 7). Then, it shows how to use these libraries in Refinitiv Real-Time SDK C/C++. The topics include:
- Build OpenSSL Libraries
- Build zlib libraries
- Build cURL Libraries
- Use the Libraries with Refinitiv Real-Time SDK C/C++
Prerequisites
To follow the steps in this article, you need to have a Linux machine, such as Centos 7 with the following packages installed.
- wget: A utility for retrieving files using the HTTP or FTP protocols
- perl-core: Base perl meta-package (Required to build OpenSSL)
- make: A GNU tool that simplifies the build process for users
- gcc: GNU Compiler Collection
You can use the following command to install these packages. The Internet connection is required to install these packages.
yum install wget.x86_64 perl-core make gcc
Build OpenSSL libraries
OpenSSL is a software library implementing the SSL and TLS protocols for applications that secure communications over computer networks. It is widely used by Internet servers, including the majority of HTTPS websites. It contains two libraries which are libssl and libcrypto. The libcrypto library provides the fundamental cryptographic routines used by libssl.
The following steps show how to build the OpenSSL libraries and a binary file from the OpenSSL source package on a Linux machine (Centos 7).
1. Download the OpenSSL source code
The OpenSSL is open source and the source code is available on the OpenSSL official website (https://www.openssl.org). The wget command can be used to download the OpenSSL source code package. At the time of this writing, the current versions of the OpenSSL packages are openssl-1.1.1n and openssl-3.0.2.
I will download the openssl-1.1.1n package but the steps mentioned in this article can also be used with the openssl-3.0.2 package.
First, change the directory to /usr/local/src. The source code of the OpenSSL package will be extracted in this directory.
cd /usr/local/src
Then, run the wget command to download the OpenSSL source package.
wget https://www.openssl.org/source/openssl-1.1.1n.tar.gz
Next, run the ls command to verify the OpenSSL source package has been downloaded properly.
2. Decompress the OpenSSL package
The OpenSSL source package file is compressed so the tar command can be used to decompress the package.
Run the following tar command to decompress the OpenSSL source package.
tar -xzvf openssl-1.1.1n.tar.gz
3. Configure the package
From the previous step, all files are extracted in the openssl-1.1.1.n directory. Change the directory to openssl-1.1.1.n.
cd openssl-1.1.1n
Then, run the config command to configure the OpenSSL source package.
./config --prefix=/opt/openssl --openssldir=/usr/local/ssl
I ran the config command with the following options.
Option | Description |
---|---|
--prefix=/opt/openssl | The top of the installation directory tree. The OpenSSL libraries will be created in this directory (/opt/openssl) |
--openssldir=/usr/local/ssl | Directory for OpenSSL configuration files, and also the default certificate and key store |
For other options, please refer to the INSTALL file in the OpenSSL source package.
4. Build the OpenSSL libraries
Run the make command to build the OpenSSL libraries (libcrypto and libssl) and the OpenSSL binary (openssl).
make
The libraries will be built in the top-level directory, and the binary will be in the apps subdirectory.
Next, run the “make test” command to test the libraries.
make test
If all tests pass, the OpenSSL libraries can be copied to other machines.
Finally, run the “make install” command to install OpenSSL on the machine.
make install
The command will install all the OpenSSL components in the directory specified in the --prefix option (/opt/openssl) and --openssldir option (/usr/local/ssl).
The libraries are in the /opt/openssl/lib directory and the OpenSSL binary file is in the /opt/openssl/bin directory.
The OpenSSL configuration files are in the /usr/local/ssl directory.
At this point, the OpenSSL binary and library files are built properly.
Build zlib Libraries
Zlib is a free and general-purpose lossless data-compression software library for use on any computer hardware and software platform, including Linux, macOS, and iOS. The zlib data format is itself portable across platforms. The following steps demonstrate how to build zlib libraries from the zlib source package on a Linux machine (Centos 7).
1. Download the zlib source code
Zlib is open source and the source code is available on the zlib official website (https://zlib.net/). The wget command can be used to download the zlib source code package. At the time of this writing, the current version of the zlib package is zlib-1.2.12.
First, change the directory to /usr/local/src. The source code of the zlib library will be extracted in this directory.
cd /usr/local/src
Then, run the wget command to download the zlib source package.
wget https://zlib.net/zlib-1.2.12.tar.gz
Next, run the ls command to verify the zlib source package has been downloaded properly.
2. Decompress the zlib source package
The zlib source package file is compressed so the tar command can be used to decompress the package.
Run the following tar command to decompress the zlib source package.
tar -xvzf zlib-1.2.12.tar.gz
3. Configure the package
From the previous step, all files are extracted in the zlib-1.2.12 directory. Change the directory to zlib-1.2.12.
cd zlib-1.2.12
Then, run the configure command to configure the zlib source package.
./configure --prefix=/opt/zlib
I ran the configure command with the following options.
Option |
Description |
---|---|
--prefix=/opt/zlib |
The top of the installation directory tree. The zlib files will be created in this directory (/opt/zlib) |
For other options, please run the “./configure --help” command.
./configure --help
4. Build the zlib libraries
Run the make command to build the zlib libraries.
make
The libraries will be built in the current directory.
Finally, run the “make install” command to install zlib on the machine.
make install
The command will install all the zlib components in the directory specified in the --prefix option (/opt/zlib). The libraries are in the /opt/zlib/lib directory.
At this point, the zlib library files are built properly.
Build cURL Library
cURL is a computer software project providing a library (libcurl) and a command-line tool (curl) for transferring data using various network protocols. It builds and works identically on many platforms. cURL supports HTTPS and performs SSL certificate verification by default when a secure protocol is specified such as HTTPS. It relies on the OpenSSL libraries to perform SSL certificate verification.
The following steps show how to build a cURL library and cURL binary file from the cURL source package on a Linux machine (Centos 7). Moreover, the cURL library and cURL binary file will use the OpenSSSL and zlib libraries created in the previous sections.
1. Download the cURL source code
The cURL is open source and the source code is available on the cURL official website (https://curl.se/download.html). The wget command can be used to download the cURL source code package. At the time of this writing, the current version of the cURL package is curl-7.83.0.
First, change the directory to /usr/local/src. The source code of the cURL library will be extracted in this directory.
cd /usr/local/src
Then, run the wget command to download the cURL source package.
wget https://curl.se/download/curl-7.83.0.tar.gz
Next, run the ls command to verify the cURL source package has been downloaded properly.
2. Decompress the cURL package
The cURL source package file is compressed so the tar command can be used to decompress the package.
Run the following tar command to decompress the cURL source package.
tar -xzvf curl-7.83.0.tar.gz
3. Configure the package
From the previous step, all files are extracted in the curl-7.83.0 directory. Change the directory to curl-7.83.0.
cd curl-7.83.0
Then, run the configure command to configure the cURL source package.
./configure --prefix /opt/curl --with-openssl=/opt/openssl --with-zlib=/opt/zlib
I ran the configure command with the following options.
Option | Description |
---|---|
--prefix=/opt/curl | The top of the installation directory tree. The cURL files will be created in this directory (/opt/curl) |
--with-openssl=/opt/openssl | Where to look for OpenSSL. PATH points to the SSL installation (/opt/openssl) |
--with-zlib=/opt/zlib | Where to look for zlib. PATH points to the zlib installation (/opt/zlib) |
For other options, please run the “./configure --help” command.
./configure --help
4. Build the cURL libraries
Run the make command to build the cURL libraries (libcurl.a and libcurl.so) and the cURL binary (curl).
make
The libraries will be built in the lib/.libs/ directory, and the binary will be in the src/.libs/ directory.
Finally, run the “make install” command to install cURL on the machine.
make install
The command will install all the cURL components in the directory specified in the --prefix option (/opt/curl). The libraries are in the /opt/curl/lib directory and the cURL binary file is in the /opt/curl/bin directory.
At this point, the cURL binary and library files are built properly.
Use the Libraries with Refinitiv Real-Time SDK C/C++
The zlib, OpenSSL, and cURL can be used with the Refinitiv Real-Time SDK C/C++ applications to connect to encrypted servers or Refinitiv Real-Time Optimized on the cloud.
1. Copy the following files to the current directory of the Refinitiv Real-Time SDK C/C++ application.
- /opt/zlib/lib/libz.so.1.2.12
- /opt/openssl/lib/libssl.so.1.1
- /opt/openssl/lib/libcrypto.so.1.1
- /opt/curl/lib/libcurl.so.4.8.0
2. Create the following soft links of those libraries.
- libz.so => libz.so.1.2.12
- libcurl.so => libcurl.so.4.8.0
The following commands can be used to create those soft links.
ln -s libz.so.1.2.12 libz.so.1
ln -s libcurl.so.4.8.0 libcurl.so
3. Add the location of the OpenSSL and cURL libraries to the LD_LIBRARY_PATH environment variable. For example, the location of the OpenSSL and cURL libraries is /opt/refinitiv/Real-Time-SDK/Cpp-C/Ema/Executables/OL7_64_GCC485/Optimized.
export LD_LIBRARY_PATH=/opt/refinitiv/Real-Time-SDK/Cpp-C/Ema/Executables/OL7_64_GCC485/Optimized
4. Verify that the certification file (cert.pem) is available in the /usr/local/ssl directory.
If the file is not there, you can create /usr/local/ssl directory and copy the cert.pem file from /etc/pki/tls directory.
cp /etc/pki/tls/cert.pem /usr/local/ssl
Otherwise, instead of copying the certificate file, you can create a soft link of that file in the /usr/local/ssl directory.
ln -s /etc/pki/tls/cert.pem /usr/local/ssl/cert.pem
5. Run the application. The application loads the OpenSSL and cURL libraries found in the LD_LIBRARAY_PATH environment variable and then connects to an encrypted server on Refitiniv Real-Time Optimized. It uses the certification file in the /usr/local/ssl directory.
Summary
OpenSSL, zlib, and cURL are open-source and popular software projects used to secure communications over computer networks, compress data, and transfer data through various network protocols. Users can easily install these packages by using the package management tool. However, the installed packages may be outdated.
Another option is building the binary packages from the project’s source code. With this method, users can get the latest version of the packages. This article demonstrates step by step to build OpenSSL, zlib, and curl libraries from the source code on a Linux machine (Centos 7). There are four steps to building the package. The first step is downloading the source code package from the official project website. The second step is decompressing the package. The third step is configuring the package and the final step is building the package. The outcome contains executable files, development libraries, header files, and man pages.
References
- cURL. n.d. cURL. [online] Available at: <https://curl.se/> [Accessed 3 May 2022].
- En.wikipedia.org. n.d. cURL - Wikipedia. [online] Available at: <https://en.wikipedia.org/wiki/CURL> [Accessed 3 May 2022].
- OpenSSL. n.d. OpenSSL. [online] Available at: <https://www.openssl.org/> [Accessed 3 May 2022].
- En.wikipedia.org. n.d. OpenSSL - Wikipedia. [online] Available at: <https://en.wikipedia.org/wiki/OpenSSL> [Accessed 3 May 2022].
- Developers.refinitiv.com. n.d. Refinitiv Real-Time C++ SDK | Refinitiv Developers. [online] Available at: <https://developers.refinitiv.com/en/api-catalog/refinitiv-real-time-opnsrc/rt-sdk-cc> [Accessed 3 May 2022].
- En.wikipedia.org. n.d. zlib - Wikipedia. [online] Available at: <https://en.wikipedia.org/wiki/Zlib> [Accessed 11 May 2022].
- Zlib.net. n.d. zlib Home Site. [online] Available at: <https://zlib.net/> [Accessed 11 May 2022].