Skip to content

Building curl with crustls and Hyper

Dirkjan Ochtman edited this page Oct 5, 2021 · 3 revisions

How to build curl with both Hyper and rustls (in debug mode):

Install the Rust toolchain: https://rustup.rs/

Clone, build, and install crustls:

git clone https://github.com/rustls/rustls-ffi $HOME/rust/rustls-ffi
cd $HOME/rust/rustls-ffi
make
sudo make install

Clone, build and install hyper:

git clone https://github.com/hyperium/hyper $HOME/rust/hyper
cd $HOME/rust/hyper
RUSTFLAGS="--cfg hyper_unstable_ffi" cargo build --features client,http1,http2,ffi
sudo install target/debug/libhyper.a /usr/local/lib/
sudo install target/debug/libhyper.so /usr/local/lib/
sudo install capi/include/hyper.h /usr/local/include/

Install autotools and libtool (distro-dependent; apt install autoconf libtool on debalikes).

Clone, configure and build curl:

git clone https://github.com/curl/curl/ $HOME/c/curl
cd $HOME/c/curl
autoreconf -fi
./configure --with-hyper --with-rustls --without-ssl --enable-debug

Verify configure output contains:

  • SSL: enabled (rustls)
  • WARNING: Hyper enabled but marked EXPERIMENTAL. Use with caution!
make -j12
export LD_LIBRARY_PATH=/usr/local/lib
./src/curl --version # verify the first line contains "rustls" and "Hyper"
./src/curl https://httpbin.org/headers -i

Or you can build with this Dockerfile:

FROM buildpack-deps:focal-scm
RUN mkdir /home/safety
ENV HOME /home/safety
WORKDIR /home/safety
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh
RUN sh rustup-init.sh -y
ENV PATH $HOME/.cargo/bin:$PATH
RUN git clone https://github.com/rustls/rustls-ffi $HOME/rust/rustls-ffi
RUN git clone https://github.com/hyperium/hyper $HOME/rust/hyper
RUN git clone https://github.com/curl/curl/ $HOME/c/curl

RUN apt update
RUN apt install -y make clang autoconf libtool

WORKDIR $HOME/rust/rustls-ffi
RUN make
RUN make install

WORKDIR $HOME/rust/hyper
RUN RUSTFLAGS="--cfg hyper_unstable_ffi" cargo build --features client,http1,http2,ffi
RUN install target/debug/libhyper.a /usr/local/lib/
RUN install target/debug/libhyper.so /usr/local/lib/
RUN install capi/include/hyper.h /usr/local/include/

WORKDIR $HOME/c/curl
RUN autoreconf -fi
RUN ./configure --with-hyper --with-rustls --without-ssl --enable-debug LDFLAGS=-L/usr/local/lib/
ENV LD_LIBRARY_PATH=/usr/local/lib
RUN make -j12
Clone this wiki locally