Page 1 of 1

MQTTs - disable hostname verification

Posted: Fri Jan 20, 2023 7:40 am
by choses-lucas
I'm currently working on MQTTs using ESP-IDF on eclipse with the ESP-IDF plugin. My goal is to adapt an existing c++ library made for POSIX to ESP32. The library currently uses PAHO and I want to replace it with the native esp32 MQTT library. And I'm currently trying the MQTTs example called ssl_mutual_auth.

For the broker, I have a test RabbitMQ and I am using self-signed certificates. Those certificates work well with the existing library using PAHO. But to make this work since it's a test installation without any hostname, just an IP and test self-signed certificate, I need to disable the hostname verification (verify that the certificate matches the given host name). Here is the documentation of that function in PAHOc++ :https://eclipse.github.io/paho.mqtt.c/M ... 2931f573ce

Right now it seems that the MQTT client (the esp32) does not accept to connect to the MQTT broker (rabbitMQ) due to this hostname verification.

Is it possible to disable this hostname verification the same way it is done in PAHO?

Re: MQTTs - disable hostname verification

Posted: Mon Jan 23, 2023 9:15 am
by ghost07

Re: MQTTs - disable hostname verification

Posted: Sat Jan 28, 2023 6:52 am
by ESP_YJM
Yes, you can set skip_cert_common_name_check(https://github.com/espressif/esp-mqtt/b ... ent.h#L260) to true to skip check server hostname in CA.

Re: MQTTs - disable hostname verification

Posted: Fri Feb 03, 2023 12:59 pm
by choses-lucas
ESP_YJM wrote: Yes, you can set skip_cert_common_name_check(https://github.com/espressif/esp-mqtt/b ... ent.h#L260) to true to skip check server hostname in CA.
Thanks, it's exactly what I needed, tested and it is working as expected.