使用TLS与mosquitto运行mosquitto经纪人时遇到错误

问题描述 投票:0回答:1

我正在尝试使用TLS通过mqtt进行通信。我在我的系统中安装了ubuntu。为了使用TLS,我使用以下链接创建了证书:

http://www.embedded101.com/Blogs/PaoloPatierno/entryid/366/mqtt-over-ssl-tls-with-the-m2mqtt-library-and-the-mosquitto-broker

我可以创建证书。我从配置文件中删除了bind_address。我正在使用mosquitto -c mosquitto_m2mqtt.conf -v的新配置文件启动mosquitto。 Mosquitto启动,但是当我运行mosquitto_sub命令时,我收到如下错误:

mosquitto -c mosquitto_m2mqtt.conf -v
1551172930: mosquitto version 1.4.8 (build date 2016-09-21 11:21:45+0530) starting
1551172930: Config loaded from mosquitto_m2mqtt.conf.
1551172930: Opening ipv4 listen socket on port 8883.
1551172930: Opening ipv6 listen socket on port 8883.
Enter PEM pass phrase:
1551172960: New connection from 127.0.0.1 on port 8883.
1551172960: OpenSSL Error: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown
1551172960: OpenSSL Error: error:140940E5:SSL routines:ssl3_read_bytes:ssl handshake failure
1551172960: Socket error on client <unknown>, disconnecting.

在我订阅的窗口中,我收到如下错误:

mosquitto_sub -p 8883 -q 1 -t sensor/temp --cafile /etc/mosquitto/m2mqtt_srv.crt --tls-version tlsv1 -d
Unable to connect (A TLS error occurred.).

以下是配置文件中添加的参数。

port 8883
cafile /etc/mosquitto/m2mqtt_ca.crt
certfile /etc/mosquitto/m2mqtt_srv.crt
keyfile /etc/mosquitto/m2mqtt_srv.key
tls_version tlsv1
ssl mqtt tls1.2 mosquitto
1个回答
0
投票

mosquitto_sub和pub需要主机地址或ip。例如,我在我的本地使用test.mosquitto.org,从该站点下载pem格式的证书文件,并将此证书添加到conf文件中作为“cafile”。这是我的命令:

mosquitto_sub -h test.mosquitto.org -t "test" -p 8883 --cafile "<pem formatted crt file path (downloaded from test.mosquitto.org)>"
© www.soinside.com 2019 - 2024. All rights reserved.