extmod/mbedtls: enable PEM parsing.#145
Closed
kwagyeman wants to merge 1 commit into
Closed
Conversation
The mbedtls config built only DER support, so the ssl module could load certificates and keys only in DER form, and `load_verify_locations` could hold just a single certificate (mbedtls >= 3.5 rejects DER buffers with trailing bytes, so concatenated DER doesn't work either). Enable MBEDTLS_PEM_PARSE_C (with its required MBEDTLS_BASE64_C) so the stack accepts PEM directly -- the format every tool emits -- and so a single `load_verify_locations(cadata=...)` can load multiple concatenated PEM certificates as a CA bundle (mbedtls_x509_crt_parse iterates PEM blocks). This is needed to verify public servers whose issuing CA rotates among several roots, where pinning one root is fragile. Costs a few KB of flash for base64 + PEM. Signed-off-by: Kwabena W. Agyeman <kwagyeman@live.com>
Member
|
Would rather not add custom stuff that we have to maintain. You can enable this per-board, for the board you need, via |
Member
Author
|
Asked upstream: micropython#19423 Yeah, it's a pretty useful feature for TLS to be usable. Boards just support one cert right now. But, if you wanted to download data from Cloudflare from a board, its root cert rotates, requiring the board to be able to support multiple certs. Should really be something all MP boards get that have TLS support. |
Member
|
Okay, you can just enable it with a custom board mbedtls config for now, better than custom patches. |
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.
The mbedtls config built only DER support, so the ssl module could load certificates and keys only in DER form, and
load_verify_locationscould hold just a single certificate (mbedtls >= 3.5 rejects DER buffers with trailing bytes, so concatenated DER doesn't work either).Enable MBEDTLS_PEM_PARSE_C (with its required MBEDTLS_BASE64_C) so the stack accepts PEM directly -- the format every tool emits -- and so a single
load_verify_locations(cadata=...)can load multiple concatenated PEM certificates as a CA bundle (mbedtls_x509_crt_parse iterates PEM blocks). This is needed to verify public servers whose issuing CA rotates among several roots, where pinning one root is fragile. Costs a few KB of flash for base64 + PEM.