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 DTLS support to MQTT-SN client #348

Closed embhorn closed 12 months ago

embhorn commented 1 year ago

Tested with mosquitto as broker, https://github.com/eclipse/paho.mqtt-sn.embedded-c as gateway.

  1. To use with local mosquitto broker, edit MQTTSNGateway/gateway.conf. Also set paths to DTLS cert / key.
    
    -BrokerName=mqtt.eclipseprojects.io
    +BrokerName=localhost

...

-DtlsCertsKey=/etc/ssl/certs/gateway.pem -DtlsPrivKey=/etc/ssl/private/privkey.pem +#DtlsCertsKey=/etc/ssl/certs/gateway.pem +DtlsCertsKey=//wolfssl/certs/server-cert.pem +#DtlsPrivKey=/etc/ssl/private/privkey.pem +DtlsPrivKey=//wolfssl/certs/server-key.pem

* I had to fix a bug in the gateway (could be related to the openssl or compiler version):

diff --git a/MQTTSNGateway/src/linux/dtls/SensorNetwork.cpp b/MQTTSNGateway/src/linux/dtls/SensorNetwork.cpp index 3f2dcf3..363d0ba 100644 --- a/MQTTSNGateway/src/linux/dtls/SensorNetwork.cpp +++ b/MQTTSNGateway/src/linux/dtls/SensorNetwork.cpp @@ -308,7 +308,7 @@ Connections::~Connections() { for (int i = 0; i < _numfds; i++) {

  1. Build wolfSSL with DTLS: ./configure --enable-dtls && make && sudo make install
  2. Build wolfMQTT with SN support: ./configure --enable-sn && make
  3. Run the broker: mosquitto
  4. Run the gateway: <gateway-folder>/MQTTSNGateway$ ./bin/MQTT-SNGateway
  5. To run the wolfMQTT sn-client example with DTLS: ./examples/sn-client/sn-client -t
embhorn commented 12 months ago

Tested and working. Perhaps add some of the PR notes into the SN example section of the README

I added a new README for the MQTT-SN examples. It was getting pretty long, so makes sense to move it.

embhorn commented 12 months ago

Ready for merge!