【问题标题】:mosquitto PSK Encryption not workingmosquitto PSK 加密不起作用
【发布时间】:2018-05-07 16:38:04
【问题描述】:

我正在尝试按照this 教程与 mosquitto 建立 PSK 加密桥连接。我正在使用两个码头集装箱。一个作为桥接器,另一个作为服务器。他们都在不同的计算机上。连接工作正常,没有加密。对于我使用 node-red 的主题的订阅。

这是服务器的配置文件:

port 1883

persistence true
persistence_location /mosquitto/data/
#persistence_file mosquitto.db
#cleansession false
#clientid nodered

listener 8883
psk_hint broker-server
psk_file /mosquitto/certs/psk_file.txt

log_type all
log_dest file /mosquitto/log/mosquitto.log
connection_messages true
log_timestamp true
allow_anonymous true
#password_file /mosquitto/config/passwd

对于网桥连接,我必须文件。

mosquitto.conf:

#include_dir /etc/mosquitto/conf.d

# GENERAL CONFIGURATION BROKER
# ----------------------------------------------------------------
pid_file /var/run/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/


log_type all
log_dest file /etc/mosquitto/log/mosquitto.log

include_dir /etc/mosquitto/bridges

# ----------------------------------------------------------------
# SECURITY (comm. Nordic -> RPI): Password

#password_file /etc/mosquitto/passwd
allow_anonymous true

还有bridge.conf:

# =================================================================
# Bridges to Node Red
# =================================================================

# IP address
#connection client-bridgeport
connection bridge-01
address 192.168.1.34:8883
bridge_identity bridgeport
bridge_psk 123456789987654321

# -----------------------------------------------------------------
# TOPICS
topic # out 1 ""
topic # in 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 false
remote_clientid broker-server
start_type automatic
#notifications false
log_type all

在服务器的日志文件中,我可以看到以下错误:

客户端未知的套接字错误,正在断开连接。

在网桥连接中我看到以下错误:

Bridge broker-server 在客户端发送 CONNECT Socket 错误 local.broker-server,正在断开连接。

我不知道我做错了什么。如果我删除加密一切正常。

【问题讨论】:

    标签: mosquitto


    【解决方案1】:

    好像mosquitto在docker hub的默认docker容器没有在mosquitto构建中包含psk加密,如this帖子所示。

    我必须构建自己的安装 mosquitto 的镜像,如下所示:

    RUN apt-get -y update && \
        apt-get -y install mosquitto mosquitto-clients
    

    【讨论】:

    • 您可能还需要更改 Dockerfile 以使用 ubuntu 进行 apk-get,即添加 FROM ubuntu:18.04
    • 哦,天哪,在使用官方 Mosquitto Docker 映像拉扯我的头发几个小时后,我遇到了这个答案。构建一个安装了 Mosquitto 的全新 Debian 容器,它很有效。 >_
    猜你喜欢
    • 1970-01-01
    • 2021-08-14
    • 2022-12-14
    • 2016-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多