FreeRTOS / iot-reference-stm32u5

MIT License
43 stars 29 forks source link

[Feature Request] Add support/sample for HTTP #72

Closed nik-markovic closed 1 year ago

nik-markovic commented 1 year ago

It would be nice if coreHTTP was supported by a reference implementation showing an example HTTPS connection being made. We need to make an HTTPS REST call before connecting to MQTT, so having a reference implementation would be very helpful.

Thanks, Nik

RichardBarry commented 1 year ago

Although not integrated into this project, you will find a set of coreHTTP demos here: https://freertos.org/mqtt/basic-mqtt-example.html

nik-markovic commented 1 year ago

HTTPS is more complex because it requires handling of the TLS connection. The part where the transport interface and handled is being set up could be board-specific and is more complex in my opinion than it should be for the end user to deal with. Also the user has to come up with re-connect logic, error handling etc., for which there are plenty of examples already in the Amazon FreeRTOS project. Ideally, an HTTPS capable client would be provided to witch the user only needs to present a TLS certificate, host/port/url, HTTP method and optional data and a callback with the response. TLS expertise is required to properly implement the MbedTLS connection, server certificate verification against the stored certificate etc., though some of it is probably available in the MQTT example.

The example that you are referring to is very rudimentary and 30 LOC compared to 300 LOC of scaffolding provided in the Amazon FreeRTOS demo here

What I am trying to say is that each one of us that needs HTTPS connectivity will have to go through the drill of understanding each one of those examples and components in depth that's probably not really needed to "just do a REST call". It is better is this complexity is dealt with by the sample project or some other reference so all could benefit from it. It is of course up to you to gauge and weigh the impact of this potential contribution, I just wanted to clarify, I guess.

Skptak commented 1 year ago

Hey @nik-markovic, I wanted to reach out and see if you had seen this resource yet: https://www.freertos.org/http/http-demo-with-tls-mutual-authentication.html Since you mentioned using a TLS connection I wanted to make sure you had seen the windows simulator demo we have that is designed to do exactly that. Additionally, here is the link to the relevant demo on github: https://github.com/FreeRTOS/FreeRTOS/tree/main/FreeRTOS-Plus/Demo/coreHTTP_Windows_Simulator/HTTP_Mutual_Auth Lastly, this link to an echo server README provides some basic instructions for how a user can set up a local HTTPS server for testing their connections. I hope this is helpful, if you need any additional guidance or help please reach out.

n9wxu commented 1 year ago

Skptak provided additional example resources that seem to satisfy the OP's request. If more help is needed, please reopen the issue.