Commit Graph

295 Commits

Author SHA1 Message Date
Ashish Sharma
15984bb8c7 test(esp_http_client): final review fixes for characterization suite
Runner now runs unfiltered; #error guard couples BASIC_AUTH to custom
transport configs; CMake include and REQUIRES cleanup; doc corrections and
tightened asserts from the final review.
2026-09-05 16:46:50 +08:00
Ashish Sharma
1abbdd0e52 test(esp_http_client): QEMU runner for characterization suite
Run the suite on QEMU (esp32c3) with timeout=600, including the
error_recovery group.
2026-09-05 16:46:50 +08:00
Ashish Sharma
68176c025e test(esp_http_client): streaming API and error path characterization
Add max_write_chunk to the mock to force real short writes and fix its
capture ordering. Pin the open/write/fetch_headers/read sequence, short-write
retry, and the header read timeout (ESP_ERR_HTTP_FETCH_HEADER).
2026-09-05 16:46:50 +08:00
Ashish Sharma
017d40bd69 test(esp_http_client): 401 auth retry characterization
Enable BASIC_AUTH in both test configs (test-only). Pin the WWW-Authenticate
retry path, the credential-less 401 retry capped by max_authorization_retries,
and the independently gated preconfigured Basic auth.
2026-09-05 16:46:50 +08:00
Ashish Sharma
f229c2ac33 test(esp_http_client): redirect characterization tests
Pin auto-follow inside one perform() call, disable_auto_redirect surfacing
the 302, and max_redirection_count tripping ESP_ERR_HTTP_MAX_REDIRECT (the
counter is checked before each redirect).
2026-09-05 16:46:49 +08:00
Ashish Sharma
78d4254750 test(esp_http_client): chunked decode and mid-chunk FIN characterization
Add read_bytes_before_error to the mock (read-side truncation budget) so the
FIN lands inside a chunk body; pins decode output and
ESP_ERR_HTTP_INCOMPLETE_DATA on truncation.
2026-09-05 16:46:49 +08:00
Ashish Sharma
13fce51d27 test(esp_http_client): keep-alive reuse and state sequence characterization
Pin transport reuse across perform() calls, the Connection: close reconnect,
and the exact get_state() sequence seen from the event handler (the getter
lags its triggering events).
2026-09-05 16:46:49 +08:00
Ashish Sharma
5b5398d927 test(esp_http_client): async EAGAIN characterization tests
Pin async connect and read would-block retry paths, and that a would-block
on the initial header send aborts the request (close + ESP_ERR_HTTP_WRITE_DATA)
instead of retrying.
2026-09-05 16:46:49 +08:00
Ashish Sharma
a30250930b test(esp_http_client): extend mock transport with async, EAGAIN injection, response queue 2026-09-05 16:46:49 +08:00
Ashish Sharma
c57e06b6a9 test(esp_http_client): add mock transport and basic characterization tests
Mock TCP transport plus 13 basic cases that pin current client behavior.
Fixture Content-Length values corrected; all mock-based cases compile only
with CONFIG_ESP_HTTP_CLIENT_ENABLE_CUSTOM_TRANSPORT.
2026-09-05 16:46:49 +08:00
yi chen
f2680c58d0 fix(esp_http_client): prevent silent truncation after read timeouts
A blocking transport read can return zero when no data arrives before
timeout. Passing that zero length to http_parser_execute signals EOF while
a response is incomplete, puts the parser in HPE_INVALID_EOF_STATE, and
causes later response bytes to be discarded. The shortened response can
then be treated as successful.

Skip parser execution for every zero-length transport read, not only async
reads. Also compare the raw esp_transport_read result against raw
ERR_TCP_TRANSPORT values so timeout and peer-close failures retain their
documented HTTP error classifications.

A standalone reproduction built with the unmodified HTTP parser showed the
blocking timeout transition to HPE_INVALID_EOF_STATE and loss of the
remaining 15 bytes. Skipping the zero-length parser call delivered the full
chunk and message-complete callback.

Disclosure: this fix was prepared with AI assistance (Claude) and reviewed by me before submission.

Constraint: esp_http_client_get_data returns raw transport result values before esp_transport_translate_error.
Rejected: Keep the async-only zero-length guard | blocking transport reads also return zero on timeout.
Confidence: high
Scope-risk: moderate
Directive: Do not pass a transient zero-length transport read to the HTTP parser as EOF.
Tested: standalone blocking mid-chunk timeout reproduction; source-only duplicate-comment cleanup; git diff --check
Not-tested: hardware TLS transport integration
Signed-off-by: yi chen <94xhn1@gmail.com>
2026-09-02 14:26:18 +08:00
Axymorrsen
22bb11ef22 fix(http_client): default Content-Type for post field 2026-08-20 08:45:04 +08:00
nilesh.kale
edb3f9daf1 fix(esp_http_client): check http_parser errno after execute to avoid DoS loop 2026-07-13 12:10:15 +05:30
Mahavir Jain
442cc028b5 Merge branch 'fix/fix_esp_http_client_cross_origin_credentials' into 'master'
fix(esp_http_client): strip Authorization header on cross-origin redirect

Closes SEC-228 and SEC-049

See merge request espressif/esp-idf!48820
2026-07-06 12:20:51 +05:30
Ashish Sharma
b939d86b8e fix(esp_http_client): fix digest-auth leaks and credential/handle use-after-free 2026-07-03 17:19:05 +08:00
Aditya Patwardhan
b5023d4343 Merge branch 'feature/unified_priv_key_interface_across_idf' into 'master'
feat(esp-tls): Added a PSA driver for Secure Element

See merge request espressif/esp-idf!44987
2026-07-02 11:00:42 +05:30
Ashish Sharma
8c181842f1 feat(esp_http_client): detect oversized headers in tx buffer while sending request
When CONFIG_ESP_HTTP_CLIENT_STRICT_HEADER_BUFFER is enabled,
esp_http_client_request_send() fails fast when a single request header is
larger than buffer_size_tx, instead of silently emitting a truncated request.

The condition is reported with a dedicated ESP_ERR_HTTP_HEADER_TOO_LONG error
code rather than overloading ESP_ERR_HTTP_WRITE_DATA, so callers can tell a
permanent header-sizing failure apart from a transient write error. errno is
cleared on this path so the async caller (which maps errno == EAGAIN to "retry
later") does not spin retrying a request that can never succeed.

Closes https://github.com/espressif/esp-idf/issues/18639

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 18:24:42 +08:00
Aditya Patwardhan
36090b7161 feat(esp-tls): Add unified private key interface via esp_key_config_t
Add ESP_KEY_SOURCE_BUFFER and ESP_KEY_SOURCE_PSA key sources so all
hardware backends (DS, ECDSA, secure element) are accessed via PSA
key IDs through a single esp_tls_cfg_t.client_key field.
2026-06-25 11:31:37 +05:30
Mahavir Jain
da6dfc30e9 Merge branch 'feat/adds_ds_qemu_test' into 'master'
feat: adds mutual auth example

Closes IDF-2681

See merge request espressif/esp-idf!45641
2026-06-04 20:43:00 +05:30
Ashish Sharma
c6e86872d6 feat(esp_http_client_mutual_auth): add mutual TLS example
Closes https://github.com/espressif/esp-idf/issues/18393
2026-05-29 11:58:25 +08:00
Guillaume Souchere
d670774f5c feat(esp_common): implement composable error code registration via link-time arrays
Refactor the esp_err_to_name() system to decouple esp_common from
higher-level components. Instead of a monolithic generated table,
each component registers its error codes into a dedicated linker
section (.esp_err_msg_table) via idf_define_esp_err_codes() in its
CMakeLists.txt.

New files:
- tools/err_codes_extract.py: extract ESP_ERR_* defines from headers to CSV
- tools/err_codes_to_c.py: generate C source placing entries into linker section
- tools/err_codes_to_rst.py: generate RST documentation from error codes
- tools/cmake/err_codes.cmake: CMake module providing idf_define_esp_err_codes()
- components/esp_common/include/esp_err_codes.h: esp_err_msg_t typedef
- components/esp_common/src/esp_err_to_name_new.c: new lookup using link-time array
- tools/test_apps/build_system/err_codes_check/: CI test app

Changes:
- Remove all optional component dependencies from esp_common/CMakeLists.txt
- Add .esp_err_msg_table section to all 5 linker scripts
- Register error codes in 18 components via idf_define_esp_err_codes()
- Add new scripts to .gitlab/ci/rules.yml build_check patterns
- use new scripts to generate doc and add CI validation
- Update esp_err.rst to add description of composable code registration
2026-05-28 09:53:32 +02:00
Aditya Patwardhan
cec6f5bff4 fix(esp_http_client): require https->https for cross-scheme redirects
esp_http_client_set_redirection() now rejects any redirect target whose
scheme is not https:// when the origin is HTTPS. This catches http, ftp,
ws and any other scheme before client state is mutated. Same-host /
https-to-https redirects are unaffected. Apps that intentionally want
mixed-scheme redirects can set disable_auto_redirect=true and handle
HTTP_EVENT_REDIRECT.
2026-05-25 21:58:14 +05:30
Ashish Sharma
a4b10f1691 fix(esp_http_client): clear URL credentials and digest auth state on host change 2026-05-22 15:16:12 +08:00
Ashish Sharma
3ba6f4b786 fix(esp_http_client): strip Authorization header on cross-origin redirect 2026-05-22 15:08:14 +08:00
Jim
f521b5f76d feat(esp_http_client): Add API to support set event handler 2026-05-11 20:27:06 +08:00
Mahavir Jain
465c0b8e22 Merge branch 'fix/chunk_encoded_post_request_failed' into 'master'
fix(esp_http_client): implement chunked transfer encoding in before tranport write

Closes IDFGH-16566

See merge request espressif/esp-idf!44362
2026-04-23 14:02:41 +05:30
nilesh.kale
c3a413a8a5 fix(esp_http_client): implement chunked transfer encoding in before tranport write
Closes https://github.com/espressif/esp-idf/issues/17685
2026-04-15 16:10:16 +05:30
Ashish Sharma
9fa73b1d89 fix(esp_http_client): fix broken connection reuse
Closes https://github.com/espressif/esp-idf/issues/18430
2026-04-10 11:47:45 +08:00
Ashish Sharma
795f0466b6 fix(esp_http_client): delete Content-Length header when using Transfer-Encoding
Closes https://github.com/espressif/esp-idf/issues/18242
2026-03-16 17:31:07 +08:00
Ashish Sharma
f0f8183281 fix: removes deprecated http_crypto sources 2026-03-03 11:16:49 +08:00
hrushikesh.bhosale
8124c2e2cf refactor(protocols): Removed the common_component dependency
- Removed the common_component build dependency from protocols test_apps
and examples
2026-02-16 15:07:37 +05:30
nilesh.kale
ba308b6d76 fix(esp_https_ota): handle ota resumption if server dosent support range requests
This commit added check to see if server supports range requets,
and fallback to OTA without resumption accordingly.

Closes https://github.com/espressif/esp-idf/pull/17960
2026-02-09 13:48:48 +05:30
Ashish Sharma
1db7fac8da feat(esp_http_client): adds support to save response headers
Closes https://github.com/espressif/esp-idf/issues/17695
2026-01-28 10:20:47 +08:00
igor.udot
4c26ab876b ci: update build-test-rules to use common_components 2026-01-23 10:14:09 +08:00
Ashish Sharma
a7abc3b8e8 feat(esp_http_client): adds API to get transport socket 2026-01-21 17:04:13 +08:00
Ashish Sharma
7093db9f10 fix(esp_http_client): fix incorrect digest calculation for SHA256 auth digest
According to RFC 7616, nonce-prime and cnonce-prime is used for SHA-256-sess only and not for SHA-256.
This commit updates the check and uses nonce only for "-sess" algorithms.

Regression from 66995965e7
2026-01-06 17:16:11 +08:00
Ashish Sharma
fdd5ef561d feat: migrates esp_http_client and esp_http_server to PSA APIs 2025-12-30 09:31:49 +05:30
C.S.M
f405e51784 ci(esp32s31): Add ci build test for esp32s31 2025-12-11 15:17:15 +08:00
Ashish Sharma
69ea28c886 feat: add Kconfig option for mbedTLS 4.x 2025-12-01 14:05:05 +08:00
Mahavir Jain
66995965e7 fix(esp_http_client): prevent out-of-bounds read in Digest auth
Fixed vulnerability where malicious HTTP servers could trigger OOB reads
by sending empty or very short algorithm fields in WWW-Authenticate headers.

Changes:
- Replace unsafe memcmp() with strcasecmp() for algorithm comparison
- Add algorithm NULL validation at function entry point
- Fix duplicate md5-sess check, add missing SHA-256 check
2025-11-21 16:36:02 +05:30
Mahavir Jain
06805d177c Merge branch 'feature/mbedtls_psa_migration_migrate_esp_http' into 'master'
Migrate esp_http_client and esp_http_server to PSA API

See merge request espressif/esp-idf!41035
2025-11-03 09:39:54 +05:30
Marius Vikhammer
cd741e995f test(system): restructured system build test test-apps 2025-10-27 09:25:07 +08:00
Ashish Sharma
acf89924c8 feat(esp_http): migrate esp_http to PSA API 2025-10-26 10:13:14 +08:00
nilesh.kale
709b869a34 feat(esp_https_ota): Support partial downloading of OTA over single connection
This commit added support to download OTA with partial download feature
over single HTTP connection if server supports persistent connection.
2025-10-10 15:42:47 +05:30
nilesh.kale
845275c6f1 fix(esp_http_client): fix dispatching of finish event condition
This commit updates the condition for dispatching of FINISH event.
With this, FINISH event will be dispatched after complete data is read.

Closes https://github.com/espressif/esp-idf/issues/17437
2025-09-11 14:18:28 +08:00
nilesh.kale
2d437a6d9a fix(esp_http_client): fixed documentation for API esp_http_client_set_post_data()
Closes https://github.com/espressif/esp-idf/issues/17053
2025-08-28 14:55:55 +05:30
Aditya Patwardhan
646377c622 Merge branch 'fix/http_client_coverity_warnings' into 'master'
fix(esp_http_client): address coverity generated warnings

Closes IDF-13867, IDF-13881, and IDF-13886

See merge request espressif/esp-idf!41411
2025-08-25 17:02:07 +05:30
Mahavir Jain
47a659cd3e Merge branch 'contrib/github_pr_17429' into 'master'
docs(esp_http_client): document default timeout behaviour (GitHub PR)

See merge request espressif/esp-idf!41363
2025-08-25 10:21:53 +05:30
Mahavir Jain
70cb9d1a5c fix(esp_http_client): address coverity generated warnings 2025-08-22 19:13:24 +05:30
Mahavir Jain
1a615729d5 Merge branch 'fix/coverity_issue_483747' into 'master'
Fix possible double memory free in esp_http_client

Closes IDF-13757, IDF-13758, and IDF-13755

See merge request espressif/esp-idf!40934
2025-08-20 14:29:20 +05:30