Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add curl easy socket backend. #380

Merged
merged 9 commits into from
Dec 11, 2023
106 changes: 106 additions & 0 deletions .github/workflows/ubuntu-check-curl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Ubuntu Build Test with Curl Support

on:
push:
branches: [ 'master', 'main', 'release/**' ]
pull_request:
branches: [ '*' ]

jobs:
build:

runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Install dependencies
run: |
# Don't prompt for anything
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
# Install mosquitto
sudo apt-get install -y mosquitto bubblewrap
- name: Setup mosquitto broker
run: |
# Disable default broker daemon
sudo service mosquitto stop
sleep 1
# This is some debug info useful if something goes wrong
- name: Show network status
run: |
sudo ifconfig
sudo route
sudo netstat -tulpan
- uses: actions/checkout@master
with:
repository: wolfssl/wolfssl
path: wolfssl
- name: wolfssl autogen
working-directory: ./wolfssl
run: ./autogen.sh
- name: wolfssl configure
working-directory: ./wolfssl
run: ./configure --enable-curl
- name: wolfssl make
working-directory: ./wolfssl
run: make
- name: wolfssl make install
working-directory: ./wolfssl
run: sudo make install

- uses: actions/checkout@master
with:
repository: curl/curl
path: curl
- name: curl autoreconf
working-directory: ./curl
run: autoreconf -fi
- name: curl configure
working-directory: ./curl
run: ./configure --with-wolfssl
- name: curl make
working-directory: ./curl
run: make
- name: curl make install
working-directory: ./curl
run: sudo make install

- uses: actions/checkout@master
- name: wolfmqtt autogen
run: ./autogen.sh

- name: wolfmqtt configure
run: ./configure
- name: wolfmqtt make
run: make
# Note: this will run the external tests for this CI only
- name: wolfmqtt make check
run: make check

- name: wolfmqtt configure with libCurl Enabled
env:
WOLFMQTT_NO_EXTERNAL_BROKER_TESTS: 1
run: ./configure --enable-curl
- name: wolfmqtt make
run: make
- name: wolfmqtt make check
run: make check

- name: wolfmqtt configure with libCurl Enabled without TLS
env:
WOLFMQTT_NO_EXTERNAL_BROKER_TESTS: 1
run: ./configure --enable-curl --disable-tls
- name: wolfmqtt make
run: make
- name: wolfmqtt make check
run: make check

# capture logs on failure
- name: Show logs on failure
if: failure() || cancelled()
run: |
cat test-suite.log
cat scripts/*.log
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,20 @@ Since the broker and subscriber are still running, you can use `mqttclient` to p

Congratulations! You have just published an MQTT message using TLS 1.3 with the `KYBER_LEVEL1` KEM and `FALCON_LEVEL1` signature scheme. To use the hybrid group, replace `KYBER_LEVEL1` with `P256_KYBER_LEVEL1`.


## Curl Easy Socket Support

wolfMQTT now supports using libcurl's easy socket interface as a backend.
When enabled, wolfMQTT will use the libcurl API for the socket backend,
and libcurl will use wolfSSL to negotiate TLS.
This can be enabled with `--enable-curl`.

At this time wolfMQTT's libcurl option supports both TLS and mTLS, but not Post-Quantum TLS.

### How to use libcurl with wolfMQTT

To use wolfMQTT with libcurl and wolfSSL:
- build wolfssl with `--enable-curl` and install to `/usr/local`.
- build libcurl with `--with-wolfssl` and install to `/usr/local`.

Finally, build wolfMQTT with `--enable-curl`.
15 changes: 15 additions & 0 deletions configure.ac
embhorn marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,19 @@ AC_CHECK_LIB([wolfssl],[wolfCrypt_Init],,[AC_MSG_ERROR([libwolfssl is required a

fi

# libcurl support
AC_ARG_ENABLE([curl],
[AS_HELP_STRING([--enable-curl],[Enable curl easy socket backend (default: disabled)])],
[ ENABLED_CURL=$enableval ],
[ ENABLED_CURL=no ]
)

if test "x$ENABLED_CURL" = "xyes"; then
AM_CFLAGS="$AM_CFLAGS -DENABLE_MQTT_CURL"

AC_CHECK_LIB([curl],[curl_easy_init],,[AC_MSG_ERROR([libcurl is required and wasn't found on the system. It can be obtained from https://curl.se/download.html.])])
fi


# Non-Blocking support
AC_ARG_ENABLE([nonblock],
Expand Down Expand Up @@ -310,6 +323,7 @@ fi


AM_CONDITIONAL([HAVE_LIBWOLFSSL], [test "x$ENABLED_TLS" = "xyes"])
AM_CONDITIONAL([HAVE_LIBCURL], [test "x$ENABLED_CURL" = "xyes"])
AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$ENABLED_EXAMPLES" = "xyes"])
AM_CONDITIONAL([BUILD_STDINCAP], [test "x$ENABLED_STDINCAP" = "xyes"])
AM_CONDITIONAL([BUILD_SN], [test "x$ENABLED_SN" = "xyes"])
Expand Down Expand Up @@ -440,4 +454,5 @@ echo " * Examples: $ENABLED_EXAMPLES"
echo " * Non-Blocking: $ENABLED_NONBLOCK"
echo " * STDIN Capture: $ENABLED_STDINCAP"
echo " * TLS: $ENABLED_TLS"
echo " * CURL: $ENABLED_CURL"
echo " * Multi-thread: $ENABLED_MULTITHREAD"
5 changes: 3 additions & 2 deletions examples/aws/awsiot.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
#include "wolfmqtt/mqtt_client.h"


/* This example only works with ENABLE_MQTT_TLS (wolfSSL library) */
#if defined(ENABLE_MQTT_TLS)
/* This example only works with ENABLE_MQTT_TLS (wolfSSL library),
* and without ENABLE_MQTT_CURL. */
#if defined(ENABLE_MQTT_TLS) && !defined(ENABLE_MQTT_CURL)
#if !defined(WOLFSSL_USER_SETTINGS) && !defined(USE_WINDOWS_API)
#include <wolfssl/options.h>
#endif
Expand Down
5 changes: 3 additions & 2 deletions examples/azure/azureiothub.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
#include "wolfmqtt/mqtt_client.h"


/* This example only works with ENABLE_MQTT_TLS (wolfSSL library) */
/* This example only works with ENABLE_MQTT_TLS (wolfSSL library)
* and without ENABLE_MQTT_CURL. */
/* Notes:
* The wolfSSL library must be built with
* #define WOLFSSL_BASE64_ENCODE
Expand All @@ -39,7 +40,7 @@
*/

/* This example requires features in wolfSSL 3.9.1 or later */
#if defined(ENABLE_MQTT_TLS)
#if defined(ENABLE_MQTT_TLS) && !defined(ENABLE_MQTT_CURL)
#if !defined(WOLFSSL_USER_SETTINGS) && !defined(USE_WINDOWS_API)
#include <wolfssl/options.h>
#endif
Expand Down
1 change: 1 addition & 0 deletions examples/firmware/fwclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "wolfmqtt/mqtt_client.h"

/* This example only works with ENABLE_MQTT_TLS (wolfSSL library). */
#if defined(ENABLE_MQTT_TLS)
#if !defined(WOLFSSL_USER_SETTINGS) && !defined(USE_WINDOWS_API)
#include <wolfssl/options.h>
Expand Down
Loading
Loading