在服务器电脑上面建立myCA文件夹, 如在/home/qa/ 文件夹下使用命令,html
mkdir myCA
而后执行如下命令,咱们将建立并使用其余用户没有权限访问的目录。python
sudo chmod 700
cd myCA
wget https://github.com/owntracks/tools/raw/master/TLS/generate-CA.sh
下载完以后,在myCA文件夹下面执行命令git
注:在生产环境中使用此实例以前,你应该定制the generate-CA.sh脚本github
bash ./generate-CA.sh
bash ./generate-CA.sh client myclient
port 8883 protocol mqtt cafile /home/myCA/ubuntu/ca.crt certfile /home/myCA/ubuntu/localhost.crt keyfile /home/myCA/ubuntu/localhost.key require_certificate true use_identity_as_username true
修改完配置文件以后,执行启动命令mosquitto -c /home/qa/mosquitto-1.4.11/mosquitto.conf -v ubuntu
参考页面:https://mosquitto.org/man/mosquitto-tls-7.htmlbash