Normalize CRLF line endings before CA chain deduplication check#781
Merged
hemanthnakkina merged 1 commit intocanonical:mainfrom Apr 23, 2026
Merged
Normalize CRLF line endings before CA chain deduplication check#781hemanthnakkina merged 1 commit intocanonical:mainfrom
hemanthnakkina merged 1 commit intocanonical:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a TLS CA chain deduplication edge case in sunbeam configure tls where the same issuing CA certificate could be appended twice when the inputs differed only by CRLF vs LF line endings.
Changes:
- Normalize decoded certificate strings from CRLF (
\r\n) to LF (\n) insidegenerate_ca_chain()before doing the “already present” check and before concatenating the final chain. - Add a unit test that reproduces the CRLF/LF mismatch case and asserts the issuing CA is not duplicated.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
sunbeam-python/sunbeam/features/interface/utils.py |
Normalizes line endings prior to CA cert presence check and chain construction to avoid duplicate CA entries. |
sunbeam-python/tests/unit/sunbeam/features/test_utils.py |
Adds a regression test ensuring CRLF/LF-equivalent CA certs are deduplicated. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
hemanthnakkina
previously approved these changes
Apr 23, 2026
a3e6903 to
0bb84d3
Compare
hemanthnakkina
approved these changes
Apr 23, 2026
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.
Fix duplicate issuing CA in certificate chain when line endings differ
Problem
When running
sunbeam configure tlswith a CA chain that already contained the issuing CA certificate, theprovide-certificateaction failed with:The root cause was in
generate_ca_chain(): it checks whetherca_certificateis already present inca_chainto avoid duplicates. However, this check failed when the two copies of the same certificate used different line endings — theca_certificatehad CRLF (\r\n) while theca_chainused LF (\n). The substring match returnedFalse, causing the issuing CA to be appended again, producing a duplicate entry thatmanual-tls-certificatesrejected as an invalid chain.Fix
Normalize all three decoded certificate strings to LF line endings before the deduplication check and before combining the chain parts. This ensures consistent comparison regardless of the source line endings.
Changes
sunbeam/features/interface/utils.py: Normalize\r\n→\ningenerate_ca_chain()before deduplication and concatenationtests/unit/sunbeam/features/test_utils.py: Add test covering the CRLF/LF deduplication case