build: add BUILD_WITH_TLS option to make TLS optional#992
Open
lukasMega wants to merge 2 commits into
Open
Conversation
Gate the TLS protocol layer behind a new CMake option BUILD_WITH_TLS (default ON), mirroring the existing BUILD_WITH_WASM / BUILD_WITH_SQLITE splits and their TJS_HAVE_* "define-when-ON" convention. When OFF, the build drops mod_tls.c, the mbedtls/mbedx509 libraries, and the libwebsockets SSL layer (LWS_WITH_SSL / LWS_WITH_MBEDTLS). libmbedcrypto is always linked, so the Web Crypto API (crypto.subtle) is unaffected. HTTPS, WSS, and TLSSocket/TLSServerSocket throw "… not supported in this build" on a NO_TLS binary; plain HTTP/WS and TCP/UDP keep working. The active feature set is exposed via tjs.engine.features.tls, and the test runner skips TLS-dependent tests (test-tls-*, test-dispose-tls, test-fetch-allow-insecure) via tests/feature-skip.json. Verified on macOS arm64: TLS=ON 255/255 tests pass; TLS=OFF 246 pass / 9 skip / 0 fail, mbedtls_ssl_* symbols absent while mbedtls_aes_* remain, binary 5.7 MB -> 5.2 MB.
# Conflicts: # CMakeLists.txt # README.md
Owner
|
I'm a bit on the fence on this one. It's the most invasive of the bunch, and the gain is not that huge. I want to hold off until I see it more clearly. |
Contributor
Author
|
Ok, no problem. I just wanted to show it. Feel free to play with it, add changes or close it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(discussion: #954)
from original big PR #962 here is extracted only support for removing TLS in build using option
BUILD_WITH_TLS:Gate the TLS protocol layer behind a new CMake option
BUILD_WITH_TLS(default ON), mirroring the existingBUILD_WITH_WASM/BUILD_WITH_SQLITEsplits and theirTJS_HAVE_*"define-when-ON" convention.When OFF, the build drops
mod_tls.c, thembedtls/mbedx509libraries, and the libwebsockets SSL layer (LWS_WITH_SSL / LWS_WITH_MBEDTLS). libmbedcrypto is always linked, so the Web Crypto API (crypto.subtle) is unaffected. HTTPS, WSS, and TLSSocket/TLSServerSocket throw "… not supported in this build" on a NO_TLS binary; plain HTTP/WS and TCP/UDP keep working.The active feature set is exposed via
tjs.engine.features.tls, and the test runner skips TLS-dependent tests (test-tls-*, test-dispose-tls, test-fetch-allow-insecure) viatests/feature-skip.json.Verified on macOS arm64:
TLS=ON 255/255 tests pass;TLS=OFF 246 pass / 9 skip / 0 fail,mbedtls_ssl_*symbols absent whilembedtls_aes_*remain, binary 5.7 MB -> 5.2 MB.my results (on macOS):