Mosquitto 設定筆記

 SSL on both sides:


0. 參考以下網頁產生憑證與設定conf

http://www.steves-internet-guide.com/creating-and-using-client-certificates-with-mqtt-and-mosquitto/

http://www.steves-internet-guide.com/mosquitto-tls/

PS: 產server.csr改用

openssl req -new -out server.csr -key server.key -config host.cnf

cnf參考:

https://blog.cssuen.tw/%E7%94%A8-san-certificate-%E5%81%9A-multi-domain-certificate-c7403e05c697

 

1. 使用以下指令啟動Docker

docker run -it --rm  -p 1883:1883 -p 8883:8883 -p 9001:9001 -v $PWD/mosquitto.conf:/mosquitto/config/mosquitto.conf -v $PWD/cert/:/mosquitto/certs/ eclipse-mosquitto

2. WSS 設定:
https://www.yunserve.dev/aiot-dev-mqtt-with-ssl/
看起來可以使用兩個憑證不衝突

3. ACL 設定:

http://www.steves-internet-guide.com/topic-restriction-mosquitto-configuration/


Golang Relay WS to TCP

因為有檢查Origin的關係,瀏覽器ok,但是一些非瀏覽器的連線會炸。所以可以這個小技巧關閉檢查

 


http.HandleFunc("/",
func(w http.ResponseWriter, req *http.Request) {
s := websocket.Server{
Handler: websocket.Handler(relayHandler)}
s.ServeHTTP(w, req)
})

留言

熱門文章