【发布时间】:2020-10-06 14:34:11
【问题描述】:
我正在尝试在我的本地网络和运行 mqtt 服务器的云之间建立一个 TLS mqtt 桥,但我无法创建它。
我已经配置了一个代理(称为 remote_broker)来接受经过证书身份验证的连接(require_certificate、use_identity_as_username、keyfile、certfile 和 cafile),并且在配置了客户端证书之后,我能够直接发布和订阅主题(使用 mosquitto_pub 和mosquitto_sub)。
当我尝试配置从另一个代理(称为 local_broker)到远程代理的网桥时,再次使用证书身份验证,它失败了。 remote_broker 中的日志显示了一个 openssl 错误,指出“对等体没有提供证书”(请参阅 remote_broker 日志)。在本地服务器上,在 SSL 握手完成之前连接被声明为失败(参见下面的 local_broker 日志),因此甚至没有启动 mqtt 会话。从日志看来,双方都在开始 TLS 握手,但由于客户端没有正确识别自己而失败。
remote_broker 日志:
2020-10-05T23:55:17Z: New connection from 127.0.0.1 on port 8883.
2020-10-05T23:55:17Z: OpenSSL Error[0]: error:1417C0C7:SSL routines:tls_process_client_certificate:peer did not return a certificate
2020-10-05T23:55:17Z: Socket error on client <unknown>, disconnecting.
local_broker 日志:
2020-10-05T23:55:17Z: Bridge local.mqttserver.local-remote doing local SUBSCRIBE on topic shelleys/#
2020-10-05T23:55:17Z: Bridge local.mqttserver.local-remote doing local SUBSCRIBE on topic tele/#
2020-10-05T23:55:17Z: Connecting bridge (step 1) local-remote (localhost:8883)
2020-10-05T23:55:17Z: Connecting bridge (step 2) local-remote (localhost:8883)
2020-10-05T23:55:17Z: Bridge mqttserver.local-remote sending CONNECT
2020-10-05T23:55:17Z: OpenSSL Error[0]: error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure
local_broker 网桥配置包含在 conf.d 目录内的一个文件中,内容如下(现在我使用 ssh 隧道访问云机器 - 因此 localhost 名称作为 remote_broker IP 地址的参考):
connection local_remote
address localhost:8883
topic shelleys/# out
topic tele/# out
bridge_cafile /etc/mosquitto/ca_certificates/RootCA.crt
bridge_certfile /etc/mosquitto/certs/bridgeClient.crt
#bridge_keyfile /etc/mosquitto/certs/bridgeClient.key
参数 bridge_keyfile 被注释掉,因为网桥连接的 local_broker 表现为客户端(或者我理解),因此不需要它,但我尝试取消注释但行为没有改变。
证书由同一个 CA 签名,其公共证书存在于两个代理中,并在 local_broker 的“bridge_cafile”和 remote_broker 的 ca_file 的配置中引用。 remote_broker 证书已颁发给“localhost”,以便它与提到的域名的地址参数匹配。
我尝试了其他几个可能影响连接行为的桥 TLS 参数,例如“bridge_insecure”、“bridge_protocol_version”、“bridge_require_ocsp”和“bridge_tls_version”,但没有一个改变行为。
有谁知道 local_broker 桥接客户端的配置中缺少什么来发送其证书并识别自己?
谢谢。
【问题讨论】:
-
如果远程代理使用 TLS 身份验证,则在充当客户端时需要密钥文件。
标签: openssl mqtt x509certificate tls1.2 mosquitto