EMQ 问答社区

MQTTX使用TLS连接emq

MQTTX使用TLS连接emq,出现如下错误

Error: Client network socket disconnected before secure TLS connection was established

看起来是TLS没有配置正确

你有配置证书吗?

是根据这篇文章配置的证书
生成的 ca.pem emqx.pem有验证 OK
在 emqx.conf 中添加了如下,并且重启了 emqx

## listener.ssl.$name is the IP address and port that the MQTT/SSL
## Value: IP:Port | Port
listener.ssl.external = 8883

## Path to the file containing the user's private PEM-encoded key.
## Value: File
listener.ssl.external.keyfile = etc/emqx/certs/emqx.key

## 注意:如果 emqx.pem 是证书链,请确保第一个证书是服务器的证书,而不是 CA 证书。
## Path to a file containing the user certificate.
## Value: File
listener.ssl.external.certfile = etc/emqx/certs/emqx.pem

## 注意:ca.pem 用于保存服务器的中间 CA 证书和根 CA 证书。可以附加其他受信任的 CA,用来进行客户端证书验证。
## Path to the file containing PEM-encoded CA certificates. The CA certificates
## Value: File
listener.ssl.external.cacertfile = etc/emqx/certs/ca.pem

暂时看不出问题,方便提供日志吗?开启一下debug级别日志