extmod/mbedtls: enable PEM parsing.#145
Open
kwagyeman wants to merge 1 commit into
Open
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>
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.