'mosquitto_sub fails with "Error: Problem setting TLS options: File not found." when using certificate files on xubuntu 20.02
I have a weird problem with mosquitto_sub 1.6.14 running on xubuntu 20.02. Everything works fine as long as I don't use certificate files. When using certificate files, I am getting "Error: Problem setting TLS options: File not found." every time. I am using the following commandline:
mosquitto_sub -h test.mosquitto.org -p 8884 -t tengo/bravo --cafile ~/test/mosquitto.org.crt --cert ~/test/returned.crt --key ~/test/client.key
When using the same command line with the same files on a fedora33 machine, everything works fine.
Can anybody help me? Please!
Solution 1:[1]
The root-cause of the problem seems to be the installation via snap. I followed the primary suggestion on https://mosquitto.org/download/ to install via snap, having the mentioned problems.
I found a post in ask-ubuntu where someone had a similar problem, where mosquito worked initially after installing with apt, but did not work anymore when reinstalling with snap.
So I tried to remove the snap installation and followed the secondary installation hints on https://mosquitto.org/download/ to install via apt.
Surprise surprise ... now it works.
Solution 2:[2]
For me when this error shows up, the problem usually is that I do not have read access to any one of the --cafile, --cert or --key files. Sometimes I have scripts that generate these files in a docker container, with a mounted drive and permissions don't align.
This error is returned when any of these files couldn't be opened. Have a look at the source code here:
https://github.com/eclipse/mosquitto/blob/master/apps/mosquitto_ctrl/options.c#L599 https://github.com/eclipse/mosquitto/blob/master/lib/options.c#L128
Solution 3:[3]
You should manually connect the mosquitto:home plug to snapd home slot, using below command.
sudo snap connect mosquitto:home snapd:home
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | volker.leeb |
Solution 2 | |
Solution 3 | Abhishek |