ESP_HTTP_REQUEST with openssl

snappeas
Posts: 2
Joined: Mon Aug 02, 2021 4:25 pm

ESP_HTTP_REQUEST with openssl

Postby snappeas » Mon Aug 02, 2021 5:05 pm

I'm working on an OTA template. If I hardcode the address of the app.bin file, the ota works perfectly. So I know my ca_cert.pem and server are working.

I'd like to be able to download the ota file address from the same server that the new app.bin file is on. I am trying to download the contents of a simple .txt file to a char buffer.

To start, I am just trying to get the length of the buffer. I can access https://httpbin.org/get just fine.
When I try to download from my local ubuntu server, it responds with HTTPS Status = 200, content_length = -1. HTTPS status 200 means it reached the server OK, so I know ca_cert.pem is working. Content length of -1 means the response is chunked, but if I call esp_http_client_is_chunked_response(), the response is 0, which means it's not chunked.

The .txt file is is on a Ubuntu openssl server. Command used: "openssl s_server -WWW -key ca_key.pem -cert ca_cert.pem -port 8000"
The address of the file is: "https://192.168.86.23:8000/hello-world-version.txt"

I know the server works in general because I can access hello-world-version.txt from the browser. Also, as I mentioned, the esp32 can download from the server for doing ota. So I'm not sure why I can't download this text file. I've also tried getting the length of the app.bin file, and it also returns content length -1.

Some other notes:
- The code attached is based on esp_http_client_example.c, I've removed a lot that I don't need
- The code attached is NOT the ota template I mentioned at the beginning
- sta_init() in app_main() comes from a function I created, I am positive that it works
- I have about 2 months of experience with esp-idf
- Using esp-idf v4.3 (just updated)

Why can't I get the length of the .txt file? Why is it telling me it is and isn't chunked?
Attachments
main.c
(5.62 KiB) Downloaded 197 times
https_request_output.png
https_request_output.png (63.81 KiB) Viewed 1319 times

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 77 guests