How can recognize an expired certificate on MQTT connection

lucilla2002
Posts: 5
Joined: Thu Sep 15, 2022 3:14 pm

How can recognize an expired certificate on MQTT connection

Postby lucilla2002 » Fri Feb 17, 2023 1:14 pm

In a MQTT connection how can I recognize the use of an expired certificate from

esp_mqtt_connect_return_code_t and esp_mqtt_error_type_t values?

I haven't expired certificates :shock: so I don't know how I can detect this situation

ESP_YJM
Posts: 300
Joined: Fri Feb 26, 2021 10:30 am

Re: How can recognize an expired certificate on MQTT connection

Postby ESP_YJM » Mon Feb 20, 2023 8:46 am

There is no API to get the reason code you want. But you can try add some log in esp_mbedtls_verify_certificate in esp_tls_mbedtls.c to print flags value. If the flags value is MBEDTLS_X509_BADCERT_EXPIRE, it means the server CA certificate is expired.

Who is online

Users browsing this forum: No registered users and 106 guests