Go: Use Mosquitto-auth-plugin to authenticate an MQTT client

Source: Internet
Author: User

Tags: dev verify mysql database Opens SQL git database load hub

https://www.lixiaodong.com/?p=163
1. Install the required packages
sudo apt-get install Libc-ares-dev libcurl4-openssl-dev Libmysqlclient-dev
2. Download the Mosquitto source code and compile the installation
Download the source code from http://mosquitto.org/download/and unzip it to a directory to compile and install the directory.
Make Mosquitto
sudo make install
3. Download Mosquitto-auth-plug Source code
git clone https://github.com/jpmens/mosquitto-auth-plug.git
and use the Copy command to generate the Config.mk file: CP config.mk.in CONFIG.MK
Edit CONFIG.MK: Select the appropriate background as needed. I only use MySQL database to authenticate the user, Backend_mysql this line is yes, the remaining lines are no. Enter the Mosquitto source path in the MOSQUITTO_SRC line, such as Mosquitto_src =/root/mosquitto-1.4.4/
。 Enter the path to OpenSSL on the Openssldir line, such as Openssldir =/usr/lib/ssl.
The path to OpenSSL can be obtained using the following command: OpenSSL version-a
4. Enter the directory where the Mosquitto-auth-plug is located and use the make command to generate the so file.
5. Move the so file to the Mosquitto directory (not the source directory, but the installed directory)
MV auth-plug.so/etc/mosquitto/
6. Edit the Mosquitto configuration file
Mosquitto-auth-plug has a variety of sample configuration files in the source code, you can use these files. For example, I use MySQL to verify that you can use the mosquitto-mysql.conf in the examples directory.
MV Mosquitto.conf Mosquitto.conf.origin (retains the original configuration file for later use)
MV Mosquitto-auth-plug directory/examples/mosquitto-mysql.conf mosquitto directory/mosquitto.conf
According to the actual situation, edit the files in the Auth_plugin,backend, database host, port, database name, user, password, SQL statements and so on.
7. Run the Mosquitto and observe the output
Mosquitto-c mosquitto-conf-v


Problem:
1. Output shows unable to load auth plugin ".../auth-plug.so"
Solve:
Edit the Config.mk:with_srv:=no under the Mosquitto source directory
And then recompile:
Make clean
Make
Generate a new so file.

Go: Use Mosquitto-auth-plugin to authenticate an MQTT client

Related Article

Beyond APAC's No.1 Cloud

19.6% IaaS Market Share in Asia Pacific - Gartner IT Service report, 2018

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.