GeezerVison is showing github.com — Validate root CA certificates on startup by vlasebian · Pull Request #7867 · TheThingsNetwork/lorawan-stack
Conversation
vlasebian
commented
Mar 26, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
Validate that certificates configured as root CAs are actually CA certificates at startup, preventing misconfiguration where a server leaf certificate is accidentally set as a root CA.
Changes
- Add
parseAndValidateCACerts function that validates PEM-encoded root CA certificates have the IsCA flag set.
- Reject non-CA (leaf) certificates, invalid PEM data, and non-CERTIFICATE PEM blocks with clear error messages.
- Use project error definitions (
errors.DefineInvalidArgument) for consistent error handling.
- Handle trailing whitespace in PEM files gracefully.
Testing
Steps
Run the unit tests:
go test ./pkg/config/tlsconfig/... -v -run TestApplyTLSClientConfig
Results
Unit tests pass.
Regressions
Client.ApplyTo now validates certificates before adding them to the root CA pool. Previously, any PEM certificate (including leaf certs) was silently accepted. Existing valid configurations are unaffected.
Notes for Reviewers
...
Checklist
- Scope: The referenced issue is addressed, there are no unrelated changes.
- Compatibility: The changes are backwards compatible with existing API, storage, configuration and CLI, according to the compatibility commitments in
README.md for the chosen target branch.
- Documentation: Relevant documentation is added or updated.
- Testing: The steps/process to test this feature are clearly explained including testing for regressions.
- Infrastructure: If infrastructural changes (e.g., new RPC, configuration) are needed, a separate issue is created in the infrastructural repositories.
- Changelog: Significant features, behavior changes, deprecations and fixes are added to
CHANGELOG.md.
- Commits: Commit messages follow guidelines in
CONTRIBUTING.md, there are no fixup commits left.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reject non-CA (leaf) certificates configured as root CAs to prevent
misconfiguration where a server leaf certificate is set as a root CA.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This branch has not been deployed
No deployments
Uh oh!
There was an error while loading. Please reload this page.
Labels
compat/config
This could affect Configuration compatibility
ui/web
This is related to a web interface
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.