在服務器電腦上面建立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