mosquitto的ssl

1、參考《https://blog.csdn.net/JKL852qaz/article/details/84034829》

https://blog.csdn.net/weixin_43025071/article/details/82491560

https://blog.csdn.net/houjixin/article/details/24305613

http://mosquitto.org/man/mosquitto-tls-7.html

2、證書(shū)校驗(yàn)

3、注意ca ,server,client,comm選項(xiàng),ca需要和client,server不同

4、注意pub,sub用root賬戶

5、主題客戶端輸入密碼和證書(shū)密碼要相同

6、注意127.0.0.1不能用,得用注冊(cè)時(shí)候client -comm選項(xiàng)ipd

測(cè)試:

啟動(dòng)服務(wù)?

sub:mosquitto_sub -h 192.168.65.131 -p 51883 -t "mqtt/server/topic" --cafile /etc/mosquitto/tls/ca.crt --cert /etc/mosquitto/tls/client.crt --key /etc/mosquitto/tls/client.key

pub:mosquitto_pub -h 192.168.65.131 -p 8883 -t "mqtt/server/topic" --cafile /etc/mosquitto/tls/ca.crt --cert /etc/mosquitto/tls/client.crt --key /etc/mosquitto/tls/client.key -m "ddddddddddd"


1、?注意事項(xiàng)

(1)??制作簽發(fā)證書(shū)的請(qǐng)求文件時(shí),需要輸入Common Name參數(shù),此參數(shù)一定為當(dāng)前主機(jī)的IP地址,否則將會(huì)顯示證書(shū)錯(cuò)誤。

(2)??如果不想SSL在身份認(rèn)證的時(shí)候檢查主機(jī)名(也即上面不檢查第1條中Common Name參數(shù)),則需要在啟動(dòng)訂閱端的時(shí)候,加上“--insecure”參數(shù),例如:

./mosquitto_sub-h 192.168.4.223 -i 111 -p 8883 -t "111" --cafile/home/jason.hou/ssl/ca.crt --cert /home/jason.hou/ssl/client.crt --key/home/jason.hou/ssl/client.key??--insecure

(3)??自測(cè)過(guò)程中,server端與所有客戶端所使用的證書(shū)必須由一個(gè)CA簽發(fā),否則,將會(huì)提示CA不識(shí)別的問(wèn)題。

問(wèn)題提示為:

1398166026:New connection from 192.168.4.221 on port 8883.

1398166026:OpenSSL Error: error:14094418:SSL routines:SSL3_READ_BYTES:tlsv1 alert unknownca

1398166026:OpenSSL Error: error:140940E5:SSL routines:SSL3_READ_BYTES:ssl handshakefailure

1398166026:Socket error on client (null), disconnecting.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容