/webassembly-curl-ssl

libcurl 8 + OpenSSL 3 compiled for WebAssembly/WASI (compatible with WAMR libsocket extension)

Primary LanguageCMakeMIT LicenseMIT

WebAssembly CURL + SSL

The project aims to compile libcurl with SSL support (OpenSSL) to WebAssembly target using WASI interfaces.

The goal of the project is to identify any gaps (performance, features) in WebAssembly/WASI to run HTTPS clients (and other clients) completely on top of WebAssembly runtime. Whereas having a full HTTPS stack implemented in WebAssembly might sound questionable, there are scenarios where the approach makes sense.

The project uses WebAssembly Micro Runtime (WAMR) WASI socket extension until the wasi-sockets proposal is not finalized.

System requirements

The project was only tested on Ubuntu 20.04 and 22.04. It will most likely compile on other Linux distributions. Windows / MacOS probably doesn't work out of the box. Contributions are very welcome.

Features

  • Protocols: DICT FILE FTP FTPS GOPHER GOPHERS HTTP HTTPS IMAP IMAPS MQTT POP3 POP3S RTSP SMTP SMTPS TELNET TFTP
  • SSL
  • IPv6
  • AsynchDNS
  • Largefile
  • alt-svc
  • HSTS
  • NTLM
  • HTTPS-proxy
  • threadsafe
  • CURL executable
  • compression (zlib)
  • WebSocket

Missing features

  • compression (brotli)
  • c-ares
  • ...

Custom patches

Dependent projects required patching in order to compile. All the patches can be found in the libs/*/*.patch. Some of the changes can be applied to upstream repositories (and we will propose them to maintainers), but some are WAMR-specific and can be removed once the wasi-sockets proposal is implemented.

Getting started

  1. Install dependencies
sudo apt install -y cmake
  1. Initialize submodules
git submodule update --init --recursive --depth 1
  1. Configure project This internally downloads WASI SDK and runs cmake command to configure the project.
./configure.sh
  1. Compile code
cmake --build build

Access compiled libraries and headers

Run the command:

cmake --install build

The compiled libraries, executables and include headers will be available in the install/ directory.

Tests / Examples

Some of the examples using libcurl can be found in tests. To run examples using WAMR, execute the command:

cmake --build build --target test

Please note the tests require valid ssl certificates to be located in build/libs_instal/ssl/certs. They can be copied from the system path, e.g. on Ubuntu it's (add -L flag to resolve symlinks):

cp -Lr /etc/ssl/certs/* build/libs_install/ssl/certs/

License

This code sample is released under the MIT license. By contributing to the project, you agree to the license and copyright terms therein and release your contribution under these terms.