Password cannot contain space character for configuration files (e.g. remote_password for bridge) #150

Closed
ralight opened this Issue Apr 28, 2016 · 2 comments

Projects

None yet

2 participants

@ralight
Contributor
ralight commented Apr 28, 2016

Migrated from https://bugs.eclipse.org/bugs/show_bug.cgi?id=492694

My question was posted on the mailing list and Mikkel Kirkgaard Nielsen digged into to it to find the real bug, he deserves the credit.

Original Post: https://dev.eclipse.org/mhonarc/lists/mosquitto-dev/msg01086.html


I tried to bridge my local mosquitto topics into the Azure IoT topics with a bridge configuration. The Azure Broker bridge connection throws a:


Client test sending CONNECT
Client test received CONNACK
Connection Refused: not authorised.

Error: The connection was refused.

As the password seems to be incorrect. In fact it isn't but it seems that the space inside of the pw breaks the parsing from the mosquitto config file which in the end transfers a wrong pw to the Azure Broker.

I am forced to use a password containing a space for Azure IoT as it is auto generated. There is no way to enclose the password inside of the bridge configuration file.

And an excerpt from the root cause as found by Mikkel:
...

The space will give you trouble as the code of src/conf.c line 1536
(http://git.eclipse.org/c/mosquitto/org.eclipse.mosquitto.git/tree/src/conf.c?h=v1.4.7#n1536)
will parse only until the first space after "remote_password", so that
is a no-go.


token = strtok_r(NULL, " ", &saveptr);


...

below is my bridge config.


connection bridge-SC-to-AzureIoT
address skoch-test01.azure-devices.net:8883
cleansession false
start_type automatic

clientid test
remote_username skoch-test01.azure-devices.net/test
remote_password SharedAccessSignature sr=foobar.azure-devices.net%2fdevices%2ftest&sig=CHANGEME2bN06SOMEMORECHARS%2bsA%3d&se=123456789

bridge_insecure false
bridge_protocol_version mqttv311
bridge_capath /etc/ssl/certs
bridge_tls_version tlsv1

notifications false
try_private false

topic # out 0 events/ devices/test/messages/events/
log_dest stdout

log_type debug

The connection through mosquitto_pub worked fine:

mosquitto_pub -d -h skoch-test01.azure-devices.net -p 8883 -u "skoch-test01.azure-devices.net/test" -P "SharedAccessSignature sr=foobar.azure-devices.net%2fdevices%2ftest&sig=CHANGEME2bN06SOMEMORECHARS%2bsA%3d&se=123456789" -i test -m "{"deviceName":"Device1","foobar_lol":10.980438438244164}" -t "devices/test/messages/events/" --tls-version tlsv1 -V mqttv311 --capath /etc/ssl/certs

Thanks in advance.
Regards,

@ralight ralight added a commit that referenced this issue Apr 28, 2016
@ralight ralight Bridge config parameters can now contain a space
Closes #150.

Thanks to Sebastian Koch and Mikkel Kirkgaard Nielsen.

Bug: #150
6704df8
@ralight
Contributor
ralight commented Apr 28, 2016

Thanks for the report, this error only affects the bridge configuration parameters, I presume because I didn't migrate them to use the "parse string" function because the error string was a different pattern.

@ralight ralight closed this Apr 28, 2016
@mikini
mikini commented Apr 28, 2016

You're welcome, this must approximate the definition of a quick fix ;).
Hope Sebastian is able to build it.

@ralight ralight added this to the 1.4.9 milestone May 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment