使用 Node.js MQTT 和 Mosquitto PSK 加密

Using Node.js MQTT with Mosquitto PSK Encryption

我正在开发一个解决方案,使用 MQTT 将数据 send/receive 传送到嵌入式系统。对于经纪人,我使用 Mosquitto. For the client I'm using Node.js MQTT.

我需要加密数据,我想使用 mosquitto 中的预共享密钥选项来完成此操作,但是,我似乎找不到 Node.js MQTT 包中内置的任何内容做这个。这可能吗?

来自 Mosquitto 配置文档:

When using pre-shared-key based encryption through the psk_hint and psk_file options, the client must provide a valid identity and key in order to connect to the broker before any MQTT communication takes place. If use_identity_as_username is true, the PSK identity is used instead of the MQTT username for access control purposes. If use_identity_as_username is false, the client may still authenticate using the MQTT username/password if using the password_file option.

似乎 MQTT 包交给了 Node 的 TLS 功能,而 Node 不支持 TLS PSK。

Preshared keys (TLS-PSK-WITH-AES-256-CBC-SHA) with node.js server