Hello,
We are trying to connect to mosquitto broker using C API libmoquitto, with TLS. We cannot establish a connection.
We have generated and configured certificates in the .conf file of the broker :
cafile ca.crt
certfile server.crt
keyfile server.key
We used Openssl suite tools to test connection against mosquitto broker using TLS, the connection seemed to work fine using these certificates.
We compiled 2 binaries for our test, one client which sends messages, one other client which consumes messages.
In the .c files, we used the mosquitto_tls_set function :
For the client which sends messages :
mosquitto_tls_set(Message_producer, “ca.crt”, NULL, “client.crt”, “client.key”, pw_callback);
We tried also with ca.crt only :
mosquitto_tls_set(Message_producer, “ca.crt”, NULL, NULL, NULL, pw_callback);
And also using a certificate without password, setting pw_callback to NULL.
We also tried to use absolute pathes in mosquitto conf file and mosquitto_tls_set function in the API.
We did the same for the client which consumes messages.
Although we are able to connect without TLS, we haven’t been able to connect with TLS until now…
We got the following messages :
In Mosquitto broker logs :
1710169333: New connection from ::1:55696 on port 1883.
1710169333: Client <unknown> disconnected due to protocol error.
1710169334: New connection from ::1:55710 on port 1883.
1710169334: Client <unknown> disconnected due to protocol error.
However, there are no error messages in the client logs, although they are not connected (When we try sending message, we have the error message : “The client is not currently connected”).
For the client which sends messages, we have the following logs :
"No error", when calling mosquitto_tls_set and mosquitto_connect.
For the client which receives messages, we have the following logs :
"No error", when calling mosquitto_tls_set and mosquitto_connect.
As these client weren’t able to connect, we guess we should have error messages.
Anybody would have and idea about that issue? Did we miss something in the configuration/.c file or is there any possibility of bug in the API?
Thanks in advance for your help.