libretiny-eu / libretiny

PlatformIO development platform for IoT modules
http://docs.libretiny.eu/
MIT License
383 stars 55 forks source link

Error connect MQTT SSL/TLS #185

Open TuanAIoT opened 9 months ago

TuanAIoT commented 9 months ago

I use CBU module, with 256dpi/MQTT@^2.5.1 library I have an MQTT connection without SSL/TLS But I have problems connecting with MQTT SSL/TLS. Don't know what the error is and how to fix it.

Thank you very much!

image image image

TuanAIoT commented 9 months ago

@kuba2k2 Can you help me, any answer can help me continue the project. i want to be connected with MQTT SSL/TLS Thanks a lot!

TuanAIoT commented 9 months ago

When I use the PubSubClient and WiFiClient libraries, when SSL/TLS is not needed, the CBU module can still connect to MQTT normally. Only when using WiFiClientSecure does it return an error status of authentication failed

So the problem is in the WiFiClientSecure library or in other words MbedTLSClient of the libretiny platform is wrong somewhere.

TuanAIoT commented 7 months ago

Hi @kuba2k2 , I posted on the TuyaOS forum to ask, but it seems that the BK7231N does not support connecting to MQTT SSL/TLS https://www.tuyaos.com/viewtopic.php?t=2432

Cossid commented 7 months ago

That is a TuyaOS/SDK limitation, not a BK7231N/T limitation. MQTT on TuyaOS does support TLS/SSL, just not with external servers, as they data they send over that wire is encrypted separately with private keys set up by their OS.

kuba2k2 commented 7 months ago

We're not using TuyaOS in LibreTiny. Of course Beken can support TLS - the mbedTLS library is there. It's just a matter of configuring it right and adapting the MQTT library to use it properly.

TuanAIoT commented 7 months ago

How to properly configure and tune the MQTT library so it can work with SSL/TLS? Sadly, I couldn't find documentation that could resolve this issue