Add tests for PEM and Traefik header DN extraction#12
Open
karlnewell wants to merge 2 commits intoworkfloworchestrator:mainfrom
Open
Add tests for PEM and Traefik header DN extraction#12karlnewell wants to merge 2 commits intoworkfloworchestrator:mainfrom
karlnewell wants to merge 2 commits intoworkfloworchestrator:mainfrom
Conversation
- Add session-scoped cert fixtures to conftest.py using cryptography to generate real self-signed certs (no mocking) - Add unit tests for _escape_dn_value, extract_dn_from_traefik_header, and extract_dn_from_pem_header including cert chain handling - Add functional tests for PEM and Info header allow/deny, priority ordering, and PEM parse failure fallback to Info header - Fix unquote_plus usage in extract_dn_from_pem_header (was unquote); Traefik's url.QueryEscape encodes spaces as '+' and base64 '+' as '%2B', so unquote_plus correctly reverses both
Traefik sends X-Forwarded-Tls-Client-Cert as raw base64-encoded DER with no PEM markers, no URL-encoding, and the full cert chain concatenated without separators. - Add _first_der_cert() to extract the leaf cert from concatenated DER bytes by parsing the ASN.1 SEQUENCE length header - Use unquote (not unquote_plus) to preserve literal '+' in base64 - Fall through to raw base64 path when no PEM markers are present - Update test fixture to match actual Traefik format (raw DER base64) - Update cert chain test to use concatenated DER base64
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.
Fixes an issue where the remote client sends a cert chain. Makes headers configurable. Adds unit and functional tests.