Page 1 of 1

How can recognize an expired certificate on MQTT connection

Posted: Fri Feb 17, 2023 1:14 pm
by lucilla2002
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

Re: How can recognize an expired certificate on MQTT connection

Posted: Mon Feb 20, 2023 8:46 am
by ESP_YJM
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.