The permissions on my dynamic-security.json file is the following:
-rw-r--r-- 1 mosquitto mosquitto 1247 Mar 6 06:51 dynamic-security.json
After trying to add a new role:
mosquitto_ctrl -u myadmin -P admin333 dynsec createRole firstRole
Also tried:
sudo mosquitto_ctrl -u myadmin -P <mypassword> dynsec createRole firstRole
I also tried it with all permissions allowed, and with the owner being the root. It all gave me the same error.
Connection error: Not authorized
The dynamic-security.json file was generated with:
sudo mosquitto_ctrl dynsec init /var/lib/mosquitto/dynamic-security.json myadmin
And this is the contents of the mosquitto.conf file:
persistence true
persistence_location /etc/mosquitto/data
user mosquitto
listener 1883
per_listener_settings false
allow_anonymous false
password_file /etc/mosquitto/conf.d/credentials
log_dest file /etc/mosquitto/log/mosquitto.log
log_dest stdout
plugin /usr/lib/x86_64-linux-gnu/mosquitto_dynamic_security.so
plugin_opt_config_file /usr/lib/x86_64-linux-gnu/dynamic-security.json
Changed the plugin_opt_config_file location in the mosquitto.conf file:
plugin_opt_config_file /etc/mosquitto/dynamic-security.json
I have also removed the old dynamic-security.json file and created a new one in the new location using:
sudo mosquitto_ctrl dynsec init /etc/mosquitto/dynamic-security.json myadmin
And then most importantly, i restarted the mosquitto.service. Now it works fine!