1. Introduction

This tutorial will show you how to compile the popular cURL library with PolarSSL as the cryptography library.
In this step-by-step tutorial Debian is used as operating system. Everything will be done from a shell.

2. Download PolarSSL

The PolarSSL library is not included in the cURL source package so we need to download and install PolarSSL first. You can use the latest version by altering the version number in the url below. Enter these statements to download and unpack the PolarSSL source code to your /home/Downloads folder:

cd ~/Downloads
wget https://polarssl.org/code/releases/polarssl-1.2.3-gpl.tgz
tar -zxf polarssl-1.2.3-gpl.tgz
cd polarssl-1.2.3

3. Compile and install PolarSSL

Now compile the source code by entering:

make

Optionally you can check that PolarSSL works correctly by entering:

make check

To install the library enter:

sudo make install

Note that you need administrator privileges to execute this command. If everything went well the PolarSSL library is now installed in /usr/local/lib.

4. Download cURL

To download and unpack the cURL source code enter these statements (you can use the latest version by altering the version number in the url):

cd ~/Downloads
wget http://curl.haxx.se/download/curl-7.28.1.tar.gz
tar -zxf curl-7.28.1.tar.gz
cd curl-7.28.1

5. Compile and install cURL

To compile cURL with PolarSSL we need to configure the build system. Normally you would use the configure script without any options, but in this case some options are needed. Enter:

./configure --without-ssl --with-polarssl

The without-ssl and with-polarssl parameters instruct the build system to use PolarSSL instead of the default ssl library.
When the configure script finishes it should state something like this:

Compile and install cURL

To compile and install cURL enter:

make
sudo make install

You will need administrator privileges to execute the second command. If everything went well the cURL program is now installed in /usr/local/bin.

6. Test cURL

To test the installation you can enter:

curl -V

This will confirm that cURL is using PolarSSL. To test the ssl capabilities of cURL we can try to retrieve an html header with an https request:

curl -I https://www.google.com/

The result should be something like this:

Test cURL

Note: If you get an libcurl.so.4: cannot open shared object file: No such file or directory error, then you need to type ldconfig first.

7. Cygwin

Some additional information for Cygwin users.

  • First of all uninstall the standard curl package from your Cygwin installation if it is installed. You can use the command cygcheck -c to print out all your installed packages.
  • Before you can wget the PolarSSL code, you need a bundle of X.509 certificates inside your Cygwin environment.
pushd /usr/ssl/certs  
curl http://curl.haxx.se/ca/cacert.pem | awk 'split_after==1{n++;split_after=0} /-----END CERTIFICATE-----/ {split_after=1} {print > "cert" n ".pem"}'  

c_rehash
  • Create an extra symlink for wget
ln -sT /usr/ssl /etc/ssl
  • Configure the cUrl build system with the following options:
./configure --without-ssl --with-polarssl=/usr/local --with-ca-bundle=/etc/ssl/certs/ca-bundle.crt

The option with-polarssl points to your PolarSSL location and with-ca-bundle is the location of your certificates bundle you extracted before.

8. Conclusion

This tutorial showed how to set up cURL with PolarSSL as the cryptography library. It is a straightforward process once you know the correct configuration options.

Did this help?