Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1084565
  • 博文数量: 80
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 746
  • 用 户 组: 普通用户
  • 注册时间: 2018-06-12 20:01
个人简介

寫写code、调調bug、填填坑,僅此而已。

文章分类

全部博文(80)

文章存档

2019年(30)

2018年(50)

分类: 网络与安全

2018-06-12 20:15:31

mosquitto桥接配置ssl证书

1.桥接时需要桥接的mosquitto服务均开启ssl


开启ssl需要在mosquitto.conf中加入以下配置:

listener 8883
cafile     /etc/mosquitto/ca_certificates/root.crt #证书文件所在路径
certfile   /etc/mosquitto/ca_certificates/server.crt #证书文件所在路径
keyfile    /etc/mosquitto/ca_certificates/server.key #证书文件所在路径

 如果需要开启websocket的ssl在mosquitto.conf的结尾加上

listener 9001
protocol websockets

require_certificate false
listener 9881
protocol websockets

cafile     /etc/mosquitto/ca_certificates/root.crt #证书文件所在路径
certfile   /etc/mosquitto/ca_certificates/server.crt #证书文件所在路径
keyfile    /etc/mosquitto/ca_certificates/server.key #证书文件所在路径


 2.配置桥接时需要加入桥接的ssl证书配置


如果只是单向验证只需要bridge_cafile就可以,如果需要双向认证,则还需要在配置文件里加入bridge_certfile、     bridge_keyfile两个参数

connection xxx(随便一个连接名字)
address xxx.xxx.xxx.xxx:8883(ip或者hostname加端口)
bridge_cafile   /etc/mosquitto/ca_certificates/root.crt #证书文件所在路径
#bridge_certfile
#bridge_keyfile

3.重启mosquitto服务使配置生效




备注:

 在生成ssl证书的server.crt时如果CommonName填写的是本机IP,则本机在桥接中需要扮演被桥接的角色,因此建议生成证书的时候CommonName填写hostname,然后再通过修改hosts将需要桥接的IP指向hostname(只需要配置桥接的机器指定hostname,被桥接的机器不需要指定)
如果生成证书时CommonName填了hostname并且有做host指向,配置桥接时的address应当填hostname+端口,例:


 /etc/hosts增加如下内容:
10.0.77.70 testca
mosquitto.conf里:
address testca:8883





阅读(2730) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~