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、证书校验

3、注意ca ,server,client,comm选项,ca需要和client,server不同

4、注意pub,sub用root账户

5、主题客户端输入密码和证书密码要相同

6、注意127.0.0.1不能用,得用注册时候client -comm选项ipd

测试:

启动服务 

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、 注意事项

(1)  制作签发证书的请求文件时,需要输入Common Name参数,此参数一定为当前主机的IP地址,否则将会显示证书错误。

(2)  如果不想SSL在身份认证的时候检查主机名(也即上面不检查第1条中Common Name参数),则需要在启动订阅端的时候,加上“--insecure”参数,例如:

./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)  自测过程中,server端与所有客户端所使用的证书必须由一个CA签发,否则,将会提示CA不识别的问题。

问题提示为:

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.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容