【发布时间】:2020-06-27 17:23:40
【问题描述】:
我在本地树莓派上有一个 mosquitto MQTT,它的工作就像一个魅力。 我在 AWS IoT 上创建了一个同样有效的 MQTT 代理。
在我的树莓派上,我可以使用 mosquitto_pub 和 mosquitto_sub 命令“手动”连接、发布和订阅 AWS 代理。 当我手动执行此操作时,我会使用所有证书和东西。我使用的命令是:
mosquitto_pub --cafile amazonCA1.pem --cert certificate.cert --key private.key -h XXXXXXXXXXXXXXXXXX.amazonaws.com -p 8883 -q 1 -d -t "iot/test" -m "testing message"
所以,我认为问题不在于证书。
问题是当我将配置更改为使用“桥接模式”时,我在 mosquitto 日志上收到以下消息:
1584371971: Connecting bridge (step 1) awsiot (XXXXXXXXXXXXXXXXXXXXX.amazonaws.com:8883)
1584371972: Connecting bridge (step 2) awsiot (XXXXXXXXXXXXXXXXXXXXX.amazonaws.com:8883)
1584371972: Bridge bridgeawsiot sending CONNECT
1584371972: OpenSSL Error: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
1584371972: Socket error on client local.bridgeawsiot, disconnecting.
1584371977: Bridge local.bridgeawsiot doing local SUBSCRIBE on topic #
这是我的 mosquitto.conf:
pid_file /var/run/mosquitto.pid
persistence true persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log log_type all
#log_dest topic
log_type error log_type warning log_type notice log_type information
connection_messages true log_timestamp true
include_dir /etc/mosquitto/conf.d
password_file /etc/mosquitto/passwordfile allow_anonymous false
这是我的 /etc/mosquitto/conf.d/bridge.conf
connection awsiot
address XXXXXXXXXXXXXXXXXXXX.amazonaws.com:8883
# Specifying which topics are bridged
topic # both 1
# Setting protocol version explicitly
bridge_protocol_version mqttv311
bridge_insecure false
# Bridge connection name and MQTT client Id,
# enabling the connection automatically when the broker starts.
cleansession true
clientid bridgeawsiot
start_type automatic
notifications false
log_type all
# =================================================================
# Certificate based SSL/TLS support
# -----------------------------------------------------------------
#Path to the rootCA
bridge_cafile /home/pi/certs/amazonCA1.pem
# Path to the PEM encoded client certificate
bridge_certfile /home/pi/certs/certificate.cert
# Path to the PEM encoded client private key
bridge_keyfile /home/pi/certs/private.key
所以,总体而言,问题是:当我手动连接/发布/订阅时,一切正常......但是当我使用桥接配置文件时,我得到了错误:
OpenSSL Error: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
有什么建议吗? 在我的本地代理(树莓派)上使用用户名/密码的身份验证方法和 AWS 上的证书身份验证是否有任何问题?
谢谢
【问题讨论】:
-
快速建议,重新排序您的
bridge.conf将log_type all移到您的网桥设置之外,因为它是一个全局选项。 -
尝试从
bridge.conf中删除log_type all,但没有任何改变。第一次尝试时 log_type 不存在,后来我添加了它。谢谢
标签: amazon-web-services mqtt mosquitto bridge broker