Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTPClient lib - add HTTPCLIENT_NOSECURE build flag #9893

Merged
merged 3 commits into from
Jun 20, 2024

Conversation

vortigont
Copy link
Contributor

Now it is impossible to use HTTPClient lib without bringing all mbedTLS stuff along, even when no https connections requred.

HTTPCLIENT_NOSECURE build flag disables TLS support in HTTPClient library by excluding NetworkClientSecure.h header.
This allows linker to strip down mbedTLS lib and certificates bundle, which in turn reduces firmware image for about ~80kib.

Could be handy for the cases when no encrypted http connections required for the sake of saving firmware size.

Tested on all HTTPClient lib examples, firmware image size reduction is about 80kib, RAM reduction is about 600 bytes.

origin:

Per-archive contributions to ELF file:
    Archive File     DRAM .data & 0.bss IRAM0 .text & 0.vectors ram_st_total Flash .text & .rodata  & flash_total
    libmbedcrypto.a         144      85          30           0          259       83098     52516         135788
    libmbedtls_2.a           72     488           0           0          560       32160      7339          39571

RAM:   [=         ]  13.3% (used 43712 bytes from 327680 bytes)
Flash: [========  ]  78.5% (used 1029069 bytes from 1310720 bytes)

this PR:

Per-archive contributions to ELF file:
    Archive File     DRAM .data & 0.bss IRAM0 .text & 0.vectors ram_st_total Flash .text & .rodata    flash_total
    libmbedcrypto.a         144      85          30           0          259       67325     41566         109065

RAM:   [=         ]  13.2% (used 43144 bytes from 327680 bytes)
Flash: [=======   ]  72.0% (used 943213 bytes from 1310720 bytes)

Copy link
Contributor

github-actions bot commented Jun 18, 2024

Warnings
⚠️

Some issues found for the commit messages in this PR:

  • the commit message "HTTPClient lib - add HTTPCLIENT_NOSECURE build flag":
    • summary looks empty
    • type/action looks empty
  • the commit message "Update HTTPClient.cpp":
    • summary looks empty
    • type/action looks empty

Please fix these commit messages - here are some basic tips:

  • follow Conventional Commits style
  • correct format of commit message should be: <type/action>(<scope/component>): <summary>, for example fix(esp32): Fixed startup timeout issue
  • allowed types are: change,ci,docs,feat,fix,refactor,remove,revert,test
  • sufficiently descriptive message summary should be between 20 to 72 characters and start with upper case letter
  • avoid Jira references in commit messages (unavailable/irrelevant for our customers)

TIP: Install pre-commit hooks and run this check when committing (uses the Conventional Precommit Linter).

Messages
📖 You might consider squashing your 3 commits (simplifying branch history).

👋 Hello vortigont, we appreciate your contribution to this project!


Click to see more instructions ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- Resolve all warnings (⚠️ ) before requesting a review from human reviewers - they will appreciate it.
- Addressing info messages (📖) is strongly recommended; they're less critical but valuable.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests.

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
4. If the change is approved and passes the tests it is merged into the default branch.

Generated by 🚫 dangerJS against 8532b18

@vortigont
Copy link
Contributor Author

@Jason2866 maybe this could be used in Tasmota's Arduino core. As I remember, it excludes mbedTLS completely, and attempt to use HTTPClient lib with Tasmota's core results in linker error for HTTPClient::begin methods. With this PR it links fine.

Copy link
Contributor

Memory usage test (comparing PR against master branch)

The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.

MemoryFLASH [bytes]FLASH [%]RAM [bytes]RAM [%]
TargetDECINCDECINCDECINCDECINC
ESP32S3000.000.00000.000.00
ESP32S2000.000.00000.000.00
ESP32C3000.000.00000.000.00
ESP32C6000.000.00000.000.00
ESP32000.000.00000.000.00
Click to expand the detailed deltas report [usage change in BYTES]
TargetESP32S3ESP32S2ESP32C3ESP32C6ESP32
ExampleFLASHRAMFLASHRAMFLASHRAMFLASHRAMFLASHRAM
HTTPClient/examples/Authorization0000000000
HTTPClient/examples/BasicHttpClient0000000000
HTTPClient/examples/BasicHttpsClient0000000000
HTTPClient/examples/HTTPClientEnterprise0000000000
HTTPClient/examples/ReuseConnection0000000000
HTTPClient/examples/StreamHttpClient0000000000

Copy link
Contributor

github-actions bot commented Jun 18, 2024

Test Results

 56 files   56 suites   5m 16s ⏱️
 21 tests  21 ✅ 0 💤 0 ❌
135 runs  135 ✅ 0 💤 0 ❌

Results for commit 8532b18.

♻️ This comment has been updated with latest results.

@lucasssvaz lucasssvaz added the Area: Libraries Issue is related to Library support. label Jun 18, 2024
@mathieucarbou
Copy link
Contributor

mathieucarbou commented Jun 18, 2024

I noticed also in my fork of ESPAsyncWebServer (https://github.com/mathieucarbou/ESPAsyncWebServer). I was able to remove the mbedtls lib on Arduino 2 by using other hash implementations (-88k), but on Arduino 3, mbedtls comes from core so cannot be skipped. Would be nice to have a way to more dynamically reduce the firmware size because libraries and code tend to use more and more space always, but our ESP32 devices are for most part still with the same flash memory.

@Jason2866
Copy link
Collaborator

@vortigont Thx for heads up. Don't see an issue using http client in our fork since the client secure code parts are completly removed

@vortigont vortigont force-pushed the notls_client branch 2 times, most recently from 2b6427f to 0a4a592 Compare June 19, 2024 08:44
`HTTPCLIENT_NOSECURE` build flag disables TLS support in HTTPClient library by
excluding `NetworkClientSecure.h` header.
This allows linker to strip down mbedTLS lind and certificates bundle,
which in turn reduces firmware image for about ~80kib.
@me-no-dev me-no-dev added Status: Pending Merge Pull Request is ready to be merged and removed Resolution: Awaiting response Waiting for response of author labels Jun 20, 2024
@me-no-dev me-no-dev merged commit 1079f4c into espressif:master Jun 20, 2024
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Libraries Issue is related to Library support. Status: Pending Merge Pull Request is ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants