ESP-IDF MQTT connection and PUB/SUB

rajneeshsinha
Posts: 4
Joined: Fri Oct 15, 2021 5:47 pm

ESP-IDF MQTT connection and PUB/SUB

Postby rajneeshsinha » Fri Oct 15, 2021 6:56 pm

Hello Support team

I worked on MQTT for AWS connection and used pub sub and it's works. I have specific requirements for MQTT connections.

Requirements details:
1. Generate and send the CSR file from ESP32 to AWS over HTTPS POST method.
2. AWS back-end code uses this CSR file and generate the certificate file (X.509 certificates generated by AWS IoT) and sending back in the response of HTTPS post #1 above.
3. Now, we have to use this received certificate to make MQTT connections.

Questions:

1. Point-1 and 2 complete and I have questions regarding point-3 mentioned above. I am not sure how to do MQTT connections using received certificate. and is there any example code available?
2. I am not much familiar with MQTT ssl and ssl_ds example and not sure these example will suite with my requirements.

Any help will be appreciated.

chegewara
Posts: 2207
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP-IDF MQTT connection and PUB/SUB

Postby chegewara » Sat Oct 16, 2021 4:46 am

When you receive certificate you can store it and then pass as argument in mqtt config struct:
https://github.com/espressif/esp-idf/bl ... #L125-L128

Now, depends what kind of cert is it you have to pass it into proper variable:
https://github.com/espressif/esp-mqtt/b ... #L186-L191

Also consult with docs:
https://docs.espressif.com/projects/esp ... 8cert_pemE

rajneeshsinha
Posts: 4
Joined: Fri Oct 15, 2021 5:47 pm

Re: ESP-IDF MQTT connection and PUB/SUB

Postby rajneeshsinha » Mon Oct 18, 2021 8:25 pm

Thanks chegewara for reply. I tried ssl example but having issue with URI. As I mentioned in my post I am working on AWS MQTT broker.
I defined URL in mqtt config struct "<custom_endpoint...>.iot.eu-central-1.amazonaws.com:8883" but it failed to connect with MQTT.

Is there am I missing something to make connection with AWS IoT core?
Do we have any example i amazon freeRTOS SDK?


rajneeshsinha
Posts: 4
Joined: Fri Oct 15, 2021 5:47 pm

Re: ESP-IDF MQTT connection and PUB/SUB

Postby rajneeshsinha » Tue Oct 19, 2021 7:10 pm

Thanks for your help it is working with ESP32 chip but I have ESP32C3 and subscribe_publish example project is not build for ESP32C3 chip set.
When I set target esp32c3 using "idf.py set-target esp32c3" command and build the project I got following error:

riscv32-esp-elf-gcc: error: unrecognized command line option '-mlongcalls'

I read the expressif document which says esp-aws-iot sdk project is available for ESP32C3 target. Following link is for reference but it redirect to me on same project which I already tried to build for esp32c3 and it's not built.

https://docs.espressif.com/projects/esp ... works.html

I know this is the another issue so I think I have to ask this new question on another tread but it will be great if you can answer.

chegewara
Posts: 2207
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP-IDF MQTT connection and PUB/SUB

Postby chegewara » Wed Oct 20, 2021 1:58 am

I believe that docs is automated build for all chip models, thats why you found a link to this repo in it.
As you can see that repo has not been updated for 5 months, so its very likely not ready to use with C3.
My advice is to open issue in that repo.

Who is online

Users browsing this forum: FrankJensen and 104 guests