开启EMQX的SSL模式及SSL证书生成流程

生成证书

首先:需要安装Openssl

以下是openssl命令

生成CA证书

bash 复制代码
1.openssl genrsa -out rootCA.key 2048 
2.openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 3650 -subj "/C=CN/ST=Shandong/L=jinan/O=yunding/OU=platform/CN=rootCA" -out rootCA.crt

生成服务端证书

bash 复制代码
1.openssl genrsa -out outkey/IoTServerEmq.key 2048  (IoTServerEmq.key  RSA加密的)
2.openssl req -new -key outkey/IoTServerEmq.key -out outkey/IoTServerEmq.csr -subj /C=CN/ST=Shandong/L=Jinan/O=yunding/OU=Iot/CN=IoTServerEmq
3.openssl pkcs8 -topk8 -in outkey/IoTServerEmq.key -out outkey/IoTServerEmq.pem -nocrypt
4.openssl x509 -req -in outkey/IoTServerEmq.csr -out outkey/IoTServerEmq.crt -CA outkey/rootCA.crt -CAkey outkey/rootCA.key -CAcreateserial -days 10950 -passin pass:password -extfile outkey/openssl3.cfg -extensions v3_req

生成client证书

bash 复制代码
1.openssl genrsa -out outkey/IoTClientDm.key 2048
2.openssl req  -new -key outkey/IoTClientDm.key -out outkey/IoTClientDm.csr -subj /C=CN/ST=Shandong/L=Jinan/O=yunding/OU=Iot/CN=IoTClientDm
3.openssl pkcs8 -topk8 -in outkey/IoTClientDm.key -out outkey/IoTClientDm.pem -nocrypt   (IoTClientDm.pem 不加密的)
4.openssl x509 -req -in outkey/IoTClientDm.csr -out outkey/IoTClientDm.crt -CA outkey/rootCA.crt -CAkey outkey/rootCA.key -CAcreateserial -days 36500 -passin pass:password -extfile outkey/openssl3.cfg -extensions v3_req

生成如下文件:

存放证书

将生成的CA证书,Server证书,Server私钥放到etc/certs目录

修改EMQX配置文件

配置emqx.conf:

证书存放地址

listener.ssl.external.keyfile = etc/certs/yunding/IoTServerEmq.key

listener.ssl.external.certfile = etc/certs/yunding/IoTServerEmq.crt

listener.ssl.external.cacertfile = etc/certs/yunding/rootCA.crt
开启端对端认证

listener.ssl.external.verify = verify_peer
强制开启双向认证,如果客户端无法提供证书,则 SSL/TLS 连接将被拒绝

listener.ssl.external.fail_if_no_peer_cert = true

客户端连接

官方手册:

获取ssl/tsl证书:

https://www.emqx.io/docs/zh/v5.1/network/tls-certificate.html#创建自签名证书
开启ssl/tsl连接:

https://www.emqx.io/docs/zh/v5.1/network/emqx-mqtt-tls.html#安全优势

相关推荐
byte轻骑兵1 小时前
【LMP】规范精讲[11]: 暗房里的协议——产线射频测试是怎么指挥芯片的
物联网·通信协议·蓝牙协议·lmp·蓝牙链路管理
芯片人0072 小时前
GEK100系列芯片进入上市公司上海移远通信供应链
人工智能·单片机·嵌入式硬件·物联网·芯片
热文新讯16 小时前
迎进博·话疗愈:2026酒店“疗愈睡眠”闭门研讨会在沪举行
大数据·人工智能·物联网
数字新视界18 小时前
机房动环监控系统助力数据中心高效能管理与安全保障
物联网·数据可视化·数据中心基础设施管理·dcim管理系统·数据中心dcim
数字新视界1 天前
数字孪生技术赋能智能化转型与创新实践
嵌入式硬件·物联网·系统架构·机房管理·动力与环境监控系统
注塑机数据采集联网1 天前
数据采集网关入门:ZK-D1/D3从零开始构建你的数据运用
大数据·数据仓库·人工智能·物联网·数据库架构·注塑机网关
智购科技智能售货柜1 天前
顾客已经关门,视觉售货柜还在处理旧画面:延迟积压怎么查?~YH
python·单片机·嵌入式硬件·物联网·eclipse
microrain1 天前
跟着一条属性报文走一遍 SagooIoT 的接入链路
物联网·架构·golang·sagooiot
笨笨饿1 天前
#60_# 一、Photoshop 2025 如何批量导出 PSD 文件中的所有图层为独立 PNG 图片
stm32·单片机·嵌入式硬件·物联网·ui·51单片机·photoshop
钱工的门窗技术笔记2 天前
室内极窄全景移门的支承路径与预留接口:轨道形式、型材壁厚口径与验收边界
物联网·架构·数据分析