openconnect-sys 0.1.0

Rust bindings for OpenConnect
openconnect-sys-0.1.0 has been yanked.
Visit the last successful build: openconnect-sys-0.1.5

Build guide

Pre-request

according to the openconnect build guide, you should install the following packages as dependencies.

Download vpnc-script if you don't have it

You can test if vpnc-script exists in your system by ls /etc/vpnc/vpnc-script or ls /usr/share/vpnc-scripts/vpnc-script. If it doesn't exist, you can download it from the openconnect project.

# you may need to run under sudo
mkdir -p /opt/vpnc-scripts
curl -o /opt/vpnc-scripts/vpnc-script https://gitlab.com/openconnect/vpnc-scripts/raw/master/vpnc-script
chmod +x /opt/vpnc-scripts/vpnc-script

For Ubuntu

apt install libxml2
apt install zlib1g zlib1g-dev
apt install openssl libssl-dev
apt install pkg-config

For building tools:

apt install automake # for aclocal
apt install libtool # for libtoolize
apt install gettext # for msgfmt

For MacOS

brew install libxml2
brew install zlib
brew install openssl
brew install pkg-config

For building tools:

brew install automake # for aclocal
brew install libtool # for libtool
brew install gettext # for msgfmt

For Windows (MSYS2 MINGW64)

Download MSYS2

Switch rust toolchain to windows-gnu

rustup default stable-x86_64-pc-windows-gnu

You have to use MSYS2 MINGW64 shell to build the library for 64-bit Windows.

pacman -S base-devel mingw-w64-x86_64-toolchain
pacman -S automake
pacman -S libtool
pacman -S gettext
pacman -S autotools
pacman -S pkg-config

pacman -S openssl openssl-devel mingw-w64-x86_64-openssl
pacman -S libxml2 libxml2-devel mingw-w64-x86_64-libxml2
pacman -S libiconv libiconv-devel mingw-w64-x86_64-libiconv
pacman -S zlib zlib-devel mingw-w64-x86_64-zlib
pacman -S liblz4 liblz4-devel mingw-w64-x86_64-lz4
pacman -S liblzma liblzma-devel mingw-w64-x86_64-xz
pacman -S icu icu-devel mingw-w64-x86_64-icu

Minor changes for Windows

  • in config.h, you may add

    #define LIBXML_STATIC
    
  • for cargo build, you have to use CFLAGS under MSYS2 MINGW64 shell, this avoid error when building rustls. See details here: https://github.com/aws/aws-lc-rs/issues/370

    For bash:

    export CFLAGS="-D_ISOC11_SOURCE" && cargo build
    

    For powershell:

    $env:CFLAGS="-D_ISOC11_SOURCE"; cargo build
    

Download source

git clone https://gitlab.com/openconnect/openconnect.git

Build static library

cd openconnect
./autogen.sh
./configure --enable-shared --enable-static \
    --with-openssl \
    --without-gssapi \
    --without-libproxy \
    --without-stoken \
    --without-libpcsclite \
    --without-libpskc \
    --without-gnutls
    # --with-vpnc-script=./vpnc-script-win.js # for windows
    # --with-vpnc-script=/opt/vpnc-scripts/vpnc-script # for *nix without vpnc-script installed
make