esp8266与mosquitto的mqtt的ssl通讯实现(三)-mosquitto配置

来源:互联网 发布:ubuntu 16.04 u盘制作 编辑:程序博客网 时间:2024/06/05 08:27

先把源代码贴出来,供大家参考,有问题请留言,后续有时间再整理。


mosquitto 配置文件:

mosquitto.conf


autosave_interval 1800persistence truepersistence_file mosquitto.dbpersistence_location /tmp/connection_messages truelog_timestamp truelog_dest stderr#log_type error#log_type warning#log_type notice#log_type information#log_type alllog_type debuglistener 1883# MQTT over TLS/SSLlistener 8883cafile /etc/mosquitto/certs/ca.crtcertfile /etc/mosquitto/certs/server.crtkeyfile /etc/mosquitto/certs/server.keyrequire_certificate true# End of MQTT over TLS/SLL configuration##   __  __       ____   ___  _     #  |  \/  |_   _/ ___| / _ \| |    #  | |\/| | | | \___ \| | | | |    #  | |  | | |_| |___) | |_| | |___ #  |_|  |_|\__, |____/ \__\_\_____|#          |___/                   #  #                     #auth_plugin /home/jpm/mosquitto-auth-plug/auth-plug.soauth_plugin /etc/mosquitto/auth-plug.soauth_opt_backends mysql#auth_opt_cdbname pwdb.cdbauth_opt_host localhostauth_opt_port 3306auth_opt_dbname mqttdbauth_opt_user rootauth_opt_pass 123456auth_opt_userquery SELECT pw FROM users WHERE username = '%s'auth_opt_superquery SELECT IFNULL(COUNT(*), 0) FROM users WHERE username = '%s' AND super = 1auth_opt_aclquery SELECT topic FROM acls WHERE username = '%s'# Usernames with this fnmatch(3) (a.k.a glob(3))  pattern are exempt from the# module's ACL checkingauth_opt_superusers S*

以上有ssl配置和mysql ACL配置,供参考






mysql导出文件,供参考,

-- MySQL dump 10.13  Distrib 5.7.17, for Linux (x86_64)---- Host: localhost    Database: mqttdb-- -------------------------------------------------------- Server version5.7.17---- Table structure for table `acls`--DROP TABLE IF EXISTS `acls`;/*!40101 SET @saved_cs_client     = @@character_set_client */;/*!40101 SET character_set_client = utf8 */;CREATE TABLE `acls` (  `id` int(11) NOT NULL AUTO_INCREMENT,  `username` varchar(25) NOT NULL,  `topic` varchar(256) NOT NULL,  `rw` int(1) NOT NULL DEFAULT '1',  PRIMARY KEY (`id`),  UNIQUE KEY `acls_user_topic` (`username`,`topic`(228))) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;/*!40101 SET character_set_client = @saved_cs_client */;---- Dumping data for table `acls`--LOCK TABLES `acls` WRITE;/*!40000 ALTER TABLE `acls` DISABLE KEYS */;INSERT INTO `acls` VALUES (1,'zhang2','loc/zhang2',1);/*!40000 ALTER TABLE `acls` ENABLE KEYS */;UNLOCK TABLES;---- Table structure for table `users`--DROP TABLE IF EXISTS `users`;/*!40101 SET @saved_cs_client     = @@character_set_client */;/*!40101 SET character_set_client = utf8 */;CREATE TABLE `users` (  `id` int(11) NOT NULL AUTO_INCREMENT,  `username` varchar(25) NOT NULL,  `pw` varchar(128) NOT NULL,  `super` int(1) NOT NULL DEFAULT '0',  PRIMARY KEY (`id`),  UNIQUE KEY `users_username` (`username`)) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;/*!40101 SET character_set_client = @saved_cs_client */;---- Dumping data for table `users`--LOCK TABLES `users` WRITE;/*!40000 ALTER TABLE `users` DISABLE KEYS */;INSERT INTO `users` VALUES (1,'zhang2','PBKDF2$sha1$98$XaIs9vQgmLujKHZG4/B3dNTbeP2PyaVKySTirZznBrE=$2DX/HZDTojVbfgAIdozBi6CihjWP1+akYnh/h9uQfIVl6pLoAiwJe1ey2WW2BnT+',0);/*!40000 ALTER TABLE `users` ENABLE KEYS */;UNLOCK TABLES;





阅读全文
0 0