Esp32 - tls - mqtt - espidf

Hey guys...
I am using ESP32 S2 and I am trying to connect to an MQTT broker which runs in my local inside a Docker in the port 8883 in TLS i can able to connect the ESP with the broker when the broker is modified to run in the 1883 but when it comes to TLS it is giving me some issues .

getting the error :
E (84613) esp-tls-mbedtls: mbedtls_x509_crt_parse of CA cert returned -0x2180
E (84613) esp-tls-mbedtls: Failed to set client configurations, returned [0x8015] (ESP_ERR_MBEDTLS_X509_CRT_PARSE_FAILED)
E (84623) esp-tls: create_ssl_handle failed
E (84623) esp-tls: Failed to open new connection
E (84633) transport_base: Failed to open a new connection
E (84643) mqtt_client: Error transport connect

I am wondering how to fix this error
The cert files are uploaded most of the formats and still i couldn't run it properly

the mosquitto cnf i am using is

const esp_mqtt_client_config_t mqtt_cfg = {
    .broker = {
        .address = {
            .uri =  brokerAddress   //"mqtts://192.168.1XX.XX:8883",
            .port = mqttPort,
            
        },
        .verification = {
            .certificate = ca_cert_file,
            .certificate_len = strlen(ca_cert_file),
            .skip_cert_common_name_check = false, // Change to true if needed
            .common_name = NULL
            //.common_name = "MyCA"
        }, 
    },
    .credentials = {
        .username = "yyyyy", // Set your MQTT broker username
        .client_id = "client_1001001",
        .authentication = {
            .password = "XXXXX",
        }
    }

and my mosquitto cnf file is

# listener for MQTT

listener 8883

# MQTT over TLS

cafile /mosquitto/config/ca.crt

certfile /mosquitto/config/server.crt

keyfile /mosquitto/config/server.key

require_certificate false

#use_identity_as_username true

# Use basic authentication with the password file

allow_anonymous false

password_file /mosquitto/config/mosquitto_passwd

# Log settings

#log_dest file /mosquitto/log/mosquitto.log

log_type all

log_timestamp true

log_timestamp_format %Y-%m-%d %H:%M:%S

# Persistence settings

persistence true

persistence_location /mosquitto/data/

# Other settings

autosave_interval 1800

# Enable protocol version 3.1.1

protocol mqtt

you googled for ESP_ERR_MBEDTLS_X509_CRT_PARSE_FAILED ?

I moved your topic to a more appropriate forum category @scg98132222.

The Nano ESP32 category you chose is only used for discussions directly related to the Arduino Nano ESP32 board.

In the future, please take the time to pick the forum category that best suits the subject of your question. There is an "About the _____ category" topic at the top of each category that explains its purpose.

Thanks in advance for your cooperation.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.