MQTT MTLS与不同的CA连接

发布于 2025-01-23 23:41:39 字数 1217 浏览 0 评论 0原文

我正在MQTT中尝试MTLS身份验证。我正在使用蚊子来实现这一目标。当我从同一CA创建服务器和客户端证书时,该连接成功。但是,如果我使用不同的CA来创建客户端证书,那么以下消息的失败

Client null sending CONNECT
OpenSSL Error[0]: error:14094418:SSL routines:ssl3_read_bytes:tlsv1 alert unknown ca
Error: The connection was lost.

是必须在MTL中使用同一CA和服务器证书使用相同的CA吗?

Mosquitto.conf

listener 8883
certfile C:\\server.crt
keyfile C:\\server.key
require_certificate true
cafile C:\mqtt-ssl-demo\ca.crt
allow_anonymous true

运行经纪使用

mosquitto -c "C:\Program Files\mosquitto\mosquitto.conf"

订阅客户端,其证书CA [Success]

mosquitto_sub --cafile C:\mqtt-ssl-demo\ca.crt -t test -d -h Computername -p 8883 --cert C:\mqtt-ssl-demo\client.crt --key C:\mqtt-ssl-demo\client.key

与客户订阅,其证书由其他CA [faff> [失败]

mosquitto_sub --cafile C:\mqtt-ssl-demo\ca.crt -t test -d -h Computername -p 8883 --cert C:\mqtt-ssl-demo\otherclient.crt --key C:\mqtt-ssl-demo\otherclient.key

创建证书使用 Mosquitto SSL配置-MQTT TLS Security

I am trying mtls authentication in MQTT. I am using mosquitto to achieve this. When I created a server and client certificate from the same CA then the connection was successful. But if I use a different CA for creating a client certificate then it's failing with the below message

Client null sending CONNECT
OpenSSL Error[0]: error:14094418:SSL routines:ssl3_read_bytes:tlsv1 alert unknown ca
Error: The connection was lost.

Is it mandatory to use the same CA for both client and server certificates in mtls?

Mosquitto.conf

listener 8883
certfile C:\\server.crt
keyfile C:\\server.key
require_certificate true
cafile C:\mqtt-ssl-demo\ca.crt
allow_anonymous true

Running broker using

mosquitto -c "C:\Program Files\mosquitto\mosquitto.conf"

Subscribe with a client with a certificate signed by server cert ca [SUCCESS]

mosquitto_sub --cafile C:\mqtt-ssl-demo\ca.crt -t test -d -h Computername -p 8883 --cert C:\mqtt-ssl-demo\client.crt --key C:\mqtt-ssl-demo\client.key

Subscribe with a client with a certificate signed by other ca [FAILURE]

mosquitto_sub --cafile C:\mqtt-ssl-demo\ca.crt -t test -d -h Computername -p 8883 --cert C:\mqtt-ssl-demo\otherclient.crt --key C:\mqtt-ssl-demo\otherclient.key

Created certificate using Mosquitto SSL Configuration -MQTT TLS Security

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

扬花落满肩 2025-01-30 23:41:39

这里要意识到的重要一点是,作为其配置的一部分,将CA文件传递给了经纪人,以验证任何连接客户端的证书。

当CA文件传递给客户端时(Mosquitto_Sub)时,用于验证经纪人提供的证书。

因此,如果您使用的是不同的CAS,那么这些文件需要不同,从您发布的CA证书中尚不清楚您使用的位置。

The important thing to realise here is that the CA file passed to the broker as part of it's config is used to verify the certificate of any connecting clients.

Where as the CA file passed to the client (mosquitto_sub) is used to verify the certificate the broker presents.

So if you are using different CAs then these files need to be different, it's not clear from what you've posted which CA certs you are using where.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文