错误的SSL/TLS连接在MQTT中与蚊子经纪人

发布于 2025-02-01 10:49:05 字数 1596 浏览 2 评论 0原文

我试图在覆盆子和蚊子经纪人之间使用openssl使用SSL/TLS加密连接。为此,我输入了以下命令:

openssl genrsa -des3 -out ca.key 2048
openssl req -new -x509 -days 2000 -key ca.key -out ca.crt
openssl genrsa -out server.key 2048
openssl req -new -out server.csr -key server.key
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 410

然后,我将CA_CERTIFIFIFICATES文件夹在/etc/Mosquitto/ca_certificates下移动,并在/etc/etc/Mosquitto/certs文件夹中移动服务器证书和键。

现在,我尝试Mosquitto -C Mosquitto.conf -v它给了我:

1653586436: The 'port' option is now deprecated and will be removed in a future version. Please use 'listener' instead.
1653586436: mosquitto version 2.0.12 starting
1653586436: Config loaded from mosquitto.conf.
1653586436: Opening ipv4 listen socket on port 8883.
1653586436: Opening ipv6 listen socket on port 8883.
1653586436: Error: Unable to load CA certificates. Check cafile "c:\etc\mosquitto\ca_certificates\ca.crt".
1653586436: Error: Unable to load server certificate "c:\etc\mosquitto\certs\server.crt". Check certfile.
1653586436: OpenSSL Error[0]: error:02001002:system library:fopen:No such file or directory
1653586436: OpenSSL Error[1]: error:20074002:BIO routines:file_ctrl:system lib
1653586436: OpenSSL Error[2]: error:140DC002:SSL routines:use_certificate_chain_file:system lib

我在Mosquitto.conf中所拥有的是:

port 8883
cafile c:\etc\mosquitto\ca_certificates\ca.crt
certfile c:\etc\mosquitto\certs\server.crt
keyfile c:\etc\mosquitto\certs\server.key

您对我的位置有任何了解错误?

I am trying to use a SSL/TLS encryption connection with openssl between a raspberry and the mosquitto broker. To do so, I have entered the following commands:

openssl genrsa -des3 -out ca.key 2048
openssl req -new -x509 -days 2000 -key ca.key -out ca.crt
openssl genrsa -out server.key 2048
openssl req -new -out server.csr -key server.key
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 410

Then I have move the ca_certificates folder under /etc/mosquitto/ca_certificates and also the server certificate and key in the /etc/mosquitto/certs folder.

Now, I try to mosquitto -c mosquitto.conf -v it gives me:

1653586436: The 'port' option is now deprecated and will be removed in a future version. Please use 'listener' instead.
1653586436: mosquitto version 2.0.12 starting
1653586436: Config loaded from mosquitto.conf.
1653586436: Opening ipv4 listen socket on port 8883.
1653586436: Opening ipv6 listen socket on port 8883.
1653586436: Error: Unable to load CA certificates. Check cafile "c:\etc\mosquitto\ca_certificates\ca.crt".
1653586436: Error: Unable to load server certificate "c:\etc\mosquitto\certs\server.crt". Check certfile.
1653586436: OpenSSL Error[0]: error:02001002:system library:fopen:No such file or directory
1653586436: OpenSSL Error[1]: error:20074002:BIO routines:file_ctrl:system lib
1653586436: OpenSSL Error[2]: error:140DC002:SSL routines:use_certificate_chain_file:system lib

What I have in the mosquitto.conf is:

port 8883
cafile c:\etc\mosquitto\ca_certificates\ca.crt
certfile c:\etc\mosquitto\certs\server.crt
keyfile c:\etc\mosquitto\certs\server.key

Do you have any idea of where is my error?

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

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

发布评论

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

评论(2

心欲静而疯不止 2025-02-08 10:49:05

我只是解决了这个问题。问题是,蚊子无法阅读文件不是因为许可问题,而是因为filepaths。

所以事情是,在定义蚊子中的filepath时,我必须使用:

cafile /etc/mosquitto/ca_certificates/ca.crt
certfile /etc/mosquitto/certs/server.crt
keyfile /etc/mosquitto/certs/server.key

而不是:

cafile c:\etc\mosquitto\ca_certificates\ca.crt
certfile c:\etc\mosquitto\certs\server.crt
keyfile c:\etc\mosquitto\certs\server.key

I just solved the issue.The problem was that mosquitto was not capable of reading the files not because of permission issues but because of the filepaths.

So the thing was that when defining the filepaths in the mosquitto.conf I had to use:

cafile /etc/mosquitto/ca_certificates/ca.crt
certfile /etc/mosquitto/certs/server.crt
keyfile /etc/mosquitto/certs/server.key

Instead of:

cafile c:\etc\mosquitto\ca_certificates\ca.crt
certfile c:\etc\mosquitto\certs\server.crt
keyfile c:\etc\mosquitto\certs\server.key
如歌彻婉言 2025-02-08 10:49:05

Mosquitto_pub的默认端口是1883,您已经配置了蚊子以使用端口8883

正确的命令行是

mosquitto_pub --cafile ca.crt -h localhost -p 8883 -t Value -m 2

因为它甚至没有到任何SSL的东西

mosquitto_pub's default port is 1883, you have configured mosquitto to use port 8883

The correct command line is

mosquitto_pub --cafile ca.crt -h localhost -p 8883 -t Value -m 2

As it is this isn't even getting to any SSL stuff

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