Welcome to the HiveMQ Community!
In the failing code, the certificate is stored as a PROGMEM
string with inconsistent indentation. Ensure that lines between -----BEGIN CERTIFICATE-----
and -----END CERTIFICATE-----
are on separate lines, without leading spaces.
Refer to this working example for guidance: ESP32 does connect to the server.
Hope this helps! Let me know if you have any questions.
Best,
Dasha from the HiveMQ Team