wolfSSL / wolfMQTT

wolfMQTT is a small, fast, portable MQTT client implementation, including support for TLS 1.3.
https://www.wolfssl.com
GNU General Public License v2.0
518 stars 156 forks source link

Add curl easy socket backend. #380

Closed philljj closed 7 months ago

philljj commented 7 months ago

Description

Added libcurl easy socket backend support for testing purposes.

Built with:

./configure --enable-curl

Prereqs

Testing

Added new curl easy socket example to examples/mqttnet.c, gated behind ENABLE_MQTT_CURL. If using TLS a CAfile can be passed in with -A:

$./examples/mqttclient/mqttclient -p 8883 -A mosquitto.org.crt -t
MQTT Client: QoS 0, Use TLS 1
MQTT Net Init: Success (0)
MQTT Init: Success (0)
*   Trying [2001:41d0:1:925e::1]:8883...
*   Trying 91.121.93.94:8883...
* Connected to test.mosquitto.org (2001:41d0:1:925e::1) port 8883
* successfully set certificate verify locations:
*  CAfile: mosquitto.org.crt
*  CApath: /etc/ssl/certs
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* using HTTP/1.x
* Connection #0 to host test.mosquitto.org left intact
MQTT Socket Connect: Success (0)
MQTT Connect: Proto (v3.1.1), Success (0)
MQTT Connect Ack: Return Code 0, Session Present 0
MQTT Subscribe: Success (0)
  Topic wolfMQTT/example/testTopic, Qos 0, Return Code 0
MQTT Publish: Topic wolfMQTT/example/testTopic, ID 2, Success (0)
MQTT Waiting for message...
MQTT Message: Topic wolfMQTT/example/testTopic, Qos 0, Len 4
Payload (0 - 4) printing 4 bytes:
test
MQTT Message: Done
$./examples/mqttclient/mqttclient -p 1883
MQTT Client: QoS 0, Use TLS 0
MQTT Net Init: Success (0)
MQTT Init: Success (0)
*   Trying [2001:41d0:1:925e::1]:1883...
* Connected to test.mosquitto.org (2001:41d0:1:925e::1) port 1883
* Connection #0 to host test.mosquitto.org left intact
MQTT Socket Connect: Success (0)
MQTT Connect: Proto (v3.1.1), Success (0)
MQTT Connect Ack: Return Code 0, Session Present 0
MQTT Subscribe: Success (0)
  Topic wolfMQTT/example/testTopic, Qos 0, Return Code 0
MQTT Publish: Topic wolfMQTT/example/testTopic, ID 2, Success (0)
MQTT Waiting for message...
MQTT Message: Topic wolfMQTT/example/testTopic, Qos 0, Len 4
Payload (0 - 4) printing 4 bytes:
test
MQTT Message: Done

Also test with:

./configure --enable-curl && make check
./configure --enable-mt --enable-nonblock CFLAGS="-DWOLFMQTT_TEST_NONBLOCK" --enable-curl  && make check

These tests are enabled and work with --enable-curl:

These tests work as well if they are enabled:

philljj commented 7 months ago

The client and firmware tests work with --enable-curl now, and the curl support includes TLS and mTLS.

Will add a github action now.

philljj commented 7 months ago

Added the curl ubuntu CI test in a separate workflow .github/workflows/ubuntu-check-curl.yml just to avoid potential side-effects between the with and without curl CI tests.

(The --enable-curl in wolfssl pulls in opensslextra and other things).

The new workflow tests these combinations:

philljj commented 7 months ago

I think several of these combinations need to be rejected in configure.ac. Looking at this.

philljj commented 7 months ago

Also, I'll document more clearly which --enable- options are compatible with --enable-curl.