From 8b53625743596d4b6d7cb0ac8a7058353dc52bd1 Mon Sep 17 00:00:00 2001 From: ading2210 Date: Wed, 22 Jan 2025 12:47:34 -0500 Subject: [PATCH] add mbedtls support and disable wolfssl --- client/build.sh | 2 +- client/javascript/copyright.js | 2 +- client/publish.sh | 1 - client/tools/all_deps.sh | 8 ++++---- client/tools/curl.sh | 4 ++-- client/tools/mbedtls.sh | 26 ++++++++++++++++++++++++++ client/tools/patch_js.py | 0 7 files changed, 34 insertions(+), 9 deletions(-) create mode 100755 client/tools/mbedtls.sh mode change 100644 => 100755 client/tools/patch_js.py diff --git a/client/build.sh b/client/build.sh index ec390aa..423d7ab 100755 --- a/client/build.sh +++ b/client/build.sh @@ -37,7 +37,7 @@ EXPORTED_FUNCS="${EXPORTED_FUNCS:1}" #compile options RUNTIME_METHODS="addFunction,removeFunction,allocate,ALLOC_NORMAL" -COMPILER_OPTIONS="-o $MODULE_FILE -lcurl -lwolfssl -lcjson -lz -lbrotlidec -lbrotlicommon -lnghttp2 -I $INCLUDE_DIR -L $LIB_DIR" +COMPILER_OPTIONS="-o $MODULE_FILE -lcurl -lmbedtls -lmbedcrypto -lmbedx509 -lcjson -lz -lbrotlidec -lbrotlicommon -lnghttp2 -I $INCLUDE_DIR -L $LIB_DIR" EMSCRIPTEN_OPTIONS="-lwebsocket.js -sENVIRONMENT=worker,web -sASSERTIONS=1 -sLLD_REPORT_UNDEFINED -sALLOW_TABLE_GROWTH -sALLOW_MEMORY_GROWTH -sNO_EXIT_RUNTIME -sEXPORTED_FUNCTIONS=$EXPORTED_FUNCS -sEXPORTED_RUNTIME_METHODS=$RUNTIME_METHODS" #clean output dir diff --git a/client/javascript/copyright.js b/client/javascript/copyright.js index d51bd98..d7d4050 100644 --- a/client/javascript/copyright.js +++ b/client/javascript/copyright.js @@ -2,7 +2,7 @@ const copyright_notice = `libcurl.js is licensed under the GNU AGPL v3. You can Several C libraries are used, and their licenses are listed below: - libcurl: curl License (https://curl.se/docs/copyright.html) -- wolfssl: GNU GPL v2 (https://github.com/wolfSSL/wolfssl/blob/master/COPYING) +- mbedtls: Apache License 2.0 (https://github.com/Mbed-TLS/mbedtls/blob/development/LICENSE) - cjson: MIT License (https://github.com/DaveGamble/cJSON/blob/master/LICENSE) - zlib: zlib License (https://www.zlib.net/zlib_license.html) - brotli: MIT License (https://github.com/google/brotli/blob/master/LICENSE) diff --git a/client/publish.sh b/client/publish.sh index 0d8c5ff..c164ff3 100755 --- a/client/publish.sh +++ b/client/publish.sh @@ -3,7 +3,6 @@ #publish libcurl.js as an npm package ./build.sh all -tests/run.sh cp package.json out cp ../README.md out diff --git a/client/tools/all_deps.sh b/client/tools/all_deps.sh index 385ad70..7c7bfc4 100755 --- a/client/tools/all_deps.sh +++ b/client/tools/all_deps.sh @@ -5,15 +5,15 @@ set -e mkdir -p build -WOLFSSL_PREFIX=$(realpath build/wolfssl-wasm) +MBEDTLS_PREFIX=$(realpath build/mbedtls-wasm) CJSON_PREFIX=$(realpath build/cjson-wasm) CURL_PREFIX=$(realpath build/curl-wasm) ZLIB_PREFIX=$(realpath build/zlib-wasm) BROTLI_PREFIX=$(realpath build/brotli-wasm) NGHTTP2_PREFIX=$(realpath build/nghttp2-wasm) -if [ ! -d $WOLFSSL_PREFIX ]; then - tools/wolfssl.sh +if [ ! -d $MBEDTLS_PREFIX ]; then + tools/mbedtls.sh fi if [ ! -d $CJSON_PREFIX ]; then tools/cjson.sh @@ -31,7 +31,7 @@ if [ ! -d $CURL_PREFIX ]; then tools/curl.sh fi -cp -r $WOLFSSL_PREFIX/* $CURL_PREFIX +cp -r $MBEDTLS_PREFIX/* $CURL_PREFIX cp -r $CJSON_PREFIX/* $CURL_PREFIX cp -r $ZLIB_PREFIX/* $CURL_PREFIX cp -r $BROTLI_PREFIX/* $CURL_PREFIX diff --git a/client/tools/curl.sh b/client/tools/curl.sh index 7f7282f..a5a405a 100755 --- a/client/tools/curl.sh +++ b/client/tools/curl.sh @@ -7,7 +7,7 @@ set -e CORE_COUNT=$(nproc --all) PREFIX=$(realpath build/curl-wasm) -WOLFSSL_PREFIX=$(realpath build/wolfssl-wasm) +MBEDTLS_PREFIX=$(realpath build/mbedtls-wasm) ZLIB_PREFIX=$(realpath build/zlib-wasm) BROTLI_PREFIX=$(realpath build/brotli-wasm) NGHTTP2_PREFIX=$(realpath build/nghttp2-wasm) @@ -24,7 +24,7 @@ emconfigure ./configure --host i686-linux \ --enable-websockets --disable-ftp --disable-file --disable-gopher \ --disable-imap --disable-mqtt --disable-pop3 --disable-rtsp \ --disable-smb --disable-smtp --disable-telnet --disable-dict \ - --with-wolfssl=$WOLFSSL_PREFIX --with-zlib=$ZLIB_PREFIX \ + --with-mbedtls=$MBEDTLS_PREFIX --with-zlib=$ZLIB_PREFIX \ --with-brotli=$BROTLI_PREFIX --with-nghttp2=$NGHTTP2_PREFIX emmake make -j$CORE_COUNT CFLAGS="-Oz" LIBS="-lbrotlicommon" diff --git a/client/tools/mbedtls.sh b/client/tools/mbedtls.sh new file mode 100755 index 0000000..0127e2c --- /dev/null +++ b/client/tools/mbedtls.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +#compile mbedtls for use with emscripten + +set -x +set -e + +CORE_COUNT=$(nproc --all) +PREFIX=$(realpath build/mbedtls-wasm) +rm -rf $PREFIX +mkdir -p $PREFIX + +cd build +rm -rf mbedtls +git clone -b mbedtls-3.6.2 --recursive --depth=1 https://github.com/Mbed-TLS/mbedtls mbedtls +cd mbedtls + +emmake make CFLAGS="-Oz" no_test -j$CORE_COUNT +make DESTDIR="$PREFIX" install + +rm -rf $PREFIX/bin +rm -rf $PREFIX/share +rm -rf $PREFIX/lib/pkgconfig +rm -rf $PREFIX/lib/*.la + +cd ../../ \ No newline at end of file diff --git a/client/tools/patch_js.py b/client/tools/patch_js.py old mode 100644 new mode 100755