Discussion:
MQTT username support
Gealber Morales via curl-library
2021-05-21 21:46:40 UTC
Permalink
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
Dan Fandrich via curl-library
2021-05-21 22:57:10 UTC
Permalink
Post by Gealber Morales via curl-library
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.
You can just leave the password blank, e.g. "-u lolo:" in the tool. The API has
had separate CURLOPT_PASSWORD and CURLOPT_USERNAME options for a long time now.
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.se/mail/etique
Gealber Morales via curl-library
2021-05-22 21:48:34 UTC
Permalink
Thanks Dan, I will manage in that way then. I will try to add also user:
password support for MQTT.
Greetings Gealber

El vie., 21 de may. de 2021 7:00 p.m., Dan Fandrich via curl-library <
Post by Gealber Morales via curl-library
Post by Gealber Morales via curl-library
In order to improve this, it would be nice to at least not be required
the
Post by Gealber Morales via curl-library
password to be supplied. Looking at the command line options, I don't
found a
Post by Gealber Morales via curl-library
way
to supply just the user. In case you know, write me back, and I'll use
that
Post by Gealber Morales via curl-library
option instead, because this one is more appropriate for supporting
user-password.
You can just leave the password blank, e.g. "-u lolo:" in the tool. The API has
had separate CURLOPT_PASSWORD and CURLOPT_USERNAME options for a long time now.
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.se/mail/etiquette.html
Loading...