hui6075 / mosquitto-cluster

a built-in, autonomous Mosquitto Cluster implementation. MQTT集群.
Other
325 stars 110 forks source link

TLS-PSK开启后,集群节点建立连接认证失败 #14

Open yinlonglyl opened 5 years ago

yinlonglyl commented 5 years ago

首先非常感谢提供mosquitto-cluster这个工具。请问目前集群是否支持TLS-PSK认证加密,node_identity和node_psk 配置生效了么?

问题描述: moquitto broker开启TLS-PSK认证后,使用mosquitto_sub/pub可以通过psk连接成功,命令如下:./mosquitto_sub --psk-identity id --psk 123456 -h 172.17.0.4 -p 8883 -t sensor/+ 但moquitto broker之间通过配置mosquitto.conf 中的node_identity和node_psk无法成功认证,mosquitto.conf集群详细配置如下: node_name node2 node_address 172.17.0.3:8883 node_identity id node_psk 123456 node_remote_clientid mqb1

node_name node3 node_address 172.17.0.4:8883 node_identity id node_psk 123456 node_remote_clientid mqb1

错误日志: 1563525650: New connection from 172.17.0.3 on port 8883. 1563525651: OpenSSL Error: error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol 1563525651: Socket error on client , disconnecting. 1563525653: [CLUSTER INIT] node node1 service maybe down, will reconnect later after 20 seconds.. 1563525653: [CLUSTER INIT] Finally handshake with node: node2 success. 1563525653: Socket error on client node2, disconnecting.

yinlonglyl commented 5 years ago

经验证mosquitto-cluster的TLS-PSK模式,默认无法认证成功。需要修改cluster.c的代码:将REAL_WITH_TLS_PSK宏定义打开,或者将其改为WITH_TLS_PSK。 目前还不清楚作者当初使用REAL_WITH_TLS_PSK未定义宏关闭cluster TLS-PSK认证的原因。