Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Agent could not perform re-connection when connecting to a MQTT broker through TLS #29

Closed
antonioboian opened this issue Oct 14, 2021 · 4 comments

Comments

@antonioboian
Copy link

Hello everyone
I would like to report the behaviour of the agent when it tries to reconnect to an MQTT broker with TLS after that the first connection fails.
The error generated is the following DEVICE_SECURITY_LoadTrustStore: X509_STORE_add_cert() failed
So in a nutshell, if the broker is up when the Agent startup the Agent will be able to perform the connection with it, if instead, the broker is not up at the Agent startup the Agent will not be able to perform the reconnection process since the DEVICE_SECURITY_LoadTrustStore function fails.
The problem is related to the fact that when performing the reconnection it is passed to the function the same SSL_CTX object, which already contains the Trust store certificates loaded earlier and therefore the function X509_STORE_add_cert() fails. For instance by commenting the first return in DEVICE_SECURITY_LoadTrustStore function everything works

@antonioboian antonioboian changed the title The Agent when connec The Agent could not perform re-connection when connecting to a MQTT broker through TLS Oct 14, 2021
@holme-r
Copy link
Contributor

holme-r commented Oct 15, 2021

I agree. The MQTT Connect callback should not be adding the trust store certs each time it is called, they only need to be added once. We will address this issue.
That said, I do not see DEVICE_SECURITY_LoadTrustStore() return a failure, so I wonder if it only occurs with certain releases of OpenSSL. I do not see the issue with OpenSSL 1.1.1c or 1.0.2g. Which version of OpenSSL do you see the issue with ?

@antonioboian
Copy link
Author

antonioboian commented Oct 18, 2021

Hi Holme-r thanks again for your answer, the version of OpenSSL I'm currently using is the 1.0.2q

@holme-r
Copy link
Contributor

holme-r commented Nov 26, 2021

Thanks, also which version of libmosquitto do you see the issue with ?

@holme-r
Copy link
Contributor

holme-r commented Dec 15, 2021

Closing, as fixed in release 5.0.0.

@holme-r holme-r closed this as completed Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants