Downloading and Using Cleansocks

The cleansocks library is available in several forms.

Binary Distribution

Ubuntu

Ubuntu is derived from the Debian distribution and uses Debian's Aptitude package manager. Two packages: libcleansocks_1.0-1.deb and libcleantlsc_1.0-1b.deb. These were built on a recent Ubuntu, but should work fine on Debian and other derivatives, such as Mint and Kali. Cleansocks is distributed in two parts, the first containing most of it, and the second the TLS client support. You'll want both for class. To install, download the files, and probably just click on them, and the GUI will figure it out how to install. To do it honestly, the command is:

apt install ./libcleansocks_1.0-1.deb ./libcleantlsc_1.0-1b.deb
The ./ notation tells apt to read the files rather than treat the file names as package names and search the repository.

Fedora

Fedora uses the Red Hat Package Manager (RPM), and for that we have: RPMs build on Fedora 36: libcleansocks-1.0-1.fc36.x86_64.rpm and libcleantlsc-1.0-1.fc36.x86_64.rpm, and on 35: libcleansocks-1.0-1.fc35.x86_64.rpm, libcleantlsc-1.0-1.fc35.x86_64.rpm. These are divided into base and TLS packages, same as the Debian packages. Again, we'll want both for class. Use the 36 if you have version 36, and choose 35 for 35 and older. In 36, Red Hat switched to a newer version of OpenSSL, and the newer builds of libcleantlsc will probably not work on the older system. (The base versions are probably interchangeable, though I haven't checked.) Download the files, and you can probably click on them, or the command is:

dnf install ./libcleansocks-1.0-1.fc36.x86_64.rpm ./libcleantlsc-1.0-1.fc36.x86_64.rpm
or
dnf install ./libcleansocks-1.0-1.fc35.x86_64.rpm ./libcleantlsc-1.0-1.fc35.x86_64.rpm

Arch Linux

Jalen Dear is an Arch fan, and has contributed cleansocks-1.0-1-x86_64.pkg.tar.zst. I don't run Arch, and am just passing along the file, and the advice that you might install it with something like

pacman -U ./cleansocks-1.0-1-x86_64.pkg.tar.zst
from the directory where the file is stored. It seems to contain both the base and tls libraries. Make sure you have the openSSL library installed also.

Windows

There is an executable installer: cleansocksinstall.exe. Download it and run it. It actually does very little; just installs the headers and library files in appropriate places. You'll need to hook them to your compiler. If you use CodeBlocks, you might also download cleanstart.zip, which is a CodeBlocks project file set up to use the library, and includes a small hello-world level program to try compiling and running. Unzip it (creating a directory cleanstart) in some appropriate place, then use CodeBlocks to open the project file cleanstart\cleanstart.cbp. That should get you started.

If you're using a different compiler, you'll have to figure out how to use the library yourself. The install puts things into subdirectories under C:/Program Files (x86)/cleansocks.

Mac

There's no Mac binary distribution, but the source should build there. See below.

What's In It?

The binary installers all install the C++ header files and appropriate library binary files needed to compile client programs using the library. The Linux cleantlsc packages require the distribution's OpenSSL packages, so the package manager will add these if needed when cleantlsc is installed. When cleantlsc is installed on Windows, the installer also installs OpenSSL and several other libraries needed to build with it. The cleantlsc RPM install requires a Fedora package which contains the root authority file. The others install a copy of the root file available here, which is the list Mozilla uses. It will be the version current when the installer was built.

Source Distribution

The source distribution is cleansocks-1.0.tgz (or cleansocks_src-1.0.zip). The library is known to build on Linux and BSD, and should work on Mac as well. Download the file, then the build uses the standard steps:

tar zfx cleansocks-1.0.tgz cd cleansocks-1.0 make make install
The last step requires admin privileges, so either use su to become root first, or try sudo make install, depending on your setup.

The build requires gnu make, which will need to be installed on BSD (and possibly Mac), and then the make steps change to gmake. If you build and install on something that isn't Red Hat Linux, you might want to follow with make locroot. Run this as yourself, not the adminstrator. It will create a .cleansocks file in your home area and download the root authority file to keep cleantlsc happy.

The source distro is not set up to build on Windows. The distributed the Windows version is cross-compiled from Fedora Linux. You could probably create a project in CodeBlocks or another IDE that you prefer and get it to build that way. You could also probably build it with the above commands under MSYS on Windows, should you have that installed.

There is also a source RPM distribution, libcleansocks-1.0-1.fc36.src.rpm.

Using the Library

A program which uses the base library (no TLS) can be compiled with a command like:

g++ -o pgm pgm.cpp -lcleansocks

You need the -l to say in which library to find the compiled methods. To compile a program which uses the cleantlsc, it's a tad longer:

g++ -o spgm spgm.cpp -lcleansocks -lcleantlsc -lssl
Here, you need to not only tell it where to find the methods from the cleansocks, including the tlsc part, but also the OpenSSL library ssl, which contains the actual TLS implementation. Depending on your installation, you may also need the option -std=c++11 on either, or the library -lcrypto for TLS.