curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

MQTT username support

From: Gealber Morales via curl-library <curl-library_at_cool.haxx.se>
Date: Fri, 21 May 2021 17:46:40 -0400

Hello there, I've been trying to add support for the use of username in the
implementation of MQTT in libcurl. I think I finally succeed, anyone that
can give me his/her opinion is welcome. To test the correctness of this
addition I made the following:

1. Ran a container of emqx/emqx listening on port 1883
2. Opened Wireshark to be able to inspect the packets sent by curl with my
modifications
3. Made the request with cURL as follows:

./curl -d 94 --user lola:passwd -v mqtt://localhost:1883/curl/mqtt

Some details here with this request:
- The -d option, is the data to be published
- In the option --user is required to be passed the password as well, but
I'm not actually making use of it.
- The last path is the topic to which the publisher want to publish data,
in our case /curl/mqtt.

In order to improve this, it would be nice to at least not be required the
password to be supplied. Looking at the command line options, I don't found
a way
to supply just the user. In case you know, write me back, and I'll use that
option instead, because this one is more appropriate for supporting
user-password.

After making the request with the modifications, all seems to go ok,
inspecting the packets in Wireshark also seems to be good. Here's a gist
with the part of the code been added and a simple modification in the
mqtt_connect
function.

mqtt.c modified, snippet
<https://gist.github.com/Gealber/f679d47e7315fd7171557b6848427f33>
<https://gist.github.com/Gealber/f679d47e7315fd7171557b6848427f33>

Let me know on any thoughts of how to improve this.

Greetings, Gealber


-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.se/mail/etiquette.html
Received on 2021-05-22