mosquitto PSK加密无法正常工作

时间:2018-05-03 09:04:27

标签: mosquitto

我正在尝试在https://docs.microsoft.com/en-us/sql/relational-databases/indexes/clustered-and-nonclustered-indexes-described?view=sql-server-2017教程之后与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,断开连接。

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

1 个答案:

答案 0 :(得分:0)

似乎docker hub中mosquitto的默认docker容器未在mos this帖子中显示的mosquitto版本中包含psk加密。

我必须建立我自己的图像安装mosquitto如下:

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