This document explains how to stunnel for the Raspberry Pi (or more precisely, for the ARM architecture). All the information here has been gathered, and adapted where needed, from these blog posts: "Cross compiling for ARM with Ubuntu 16.04 LTS" and "Cross-compile OpenSSL for your Raspberry Pi". I needed to do that in order to be able to use my Raspberry Pi to provide Internet via WiFi for my Ethernet-only MSX. The OS I used as the building host is Linux Mint 18.3.
This is just a concise recipe and I'm not going to explain the details, feel free to take a look at the linked blog posts for more information.
First we are going to create a temporary directory for all the dirty work.
cd ~/
mkdir build_stunnel
cd build_stunnel
Then we'll install the ARM cross development tools:
sudo apt-get install git gcc make autoconf gcc-arm-linux-gnueabi g++-arm-linux-gnueabi binutils-arm-linux-gnueabi
git clone https://github.com/raspberrypi/tools.git --depth=1 pitools
The following commands will clone and build OpenSSL for ARM, it's a prerequisite for building stunnel:
git clone --single-branch --branch OpenSSL_1_1_1-stable https://github.com/openssl/openssl.git
cd openssl
export CROSSCOMP_DIR=~/build_stunnel/pitools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin
export INSTALL_DIR=~/build_stunnel/openssl_arm
./Configure linux-generic32 shared \
--prefix=$INSTALL_DIR --openssldir=$INSTALL_DIR/openssl \
--cross-compile-prefix=$CROSSCOMP_DIR/arm-linux-gnueabihf-
make
make install
cd ..
Now let's download the stunnel sources. If you want to get them from the official repositories run the following:
git clone https://github.com/mtrojnar/stunnel.git
However, if you want to get my modified version with SOCKS SSL support run this instead:
git clone --single-branch --branch socks-server-with-ssl-on-remote https://github.com/Konamiman/stunnel.git
Now let's go ahead and build it:
cd stunnel
./configure --with-ssl=$INSTALL_DIR --build x86_64-pc-linux-gnu --host arm-linux-gnueabi
autoreconf -f -i
make
That's it, the compiled stunnel
is located at ~/build_stunnel/stunnel/src
. You need to make it executable with chmod +x ~/build_stunnel/stunnel/src/stunnel
and you're done.
In order to copy the compiled stunnel to your Pi you can use scp:
scp ~/build_stunnel/stunnel/src/stunnel [email protected]:~/
(if you have changed the username to something different than pi
, or your Pi isn't accessible via host name, change the [email protected]
as appropriate)
Finally, that's how you cleanup all the stunnel and OpenSSL intermediate files from your Linux system:
cd ~/
rm -rf build_stunnel
Hi Bro,
Thanks but these tools are not available anymore :(
g++-arm-linux-gnueabi binutils-arm-linux-gnueabi
I fixed using stunnel4 on my Bash for Windows (WSL 2). Working good. No need to build it.