fix(nats): validate cert+key parity at config time#459
Merged
Conversation
✅ Dependency Audit
See the Security tab for detailed findings. Workflow: Dependency Audit |
Security Scan Results
Recommendations
Workflow: Security Scanning |
…#276) Add NatsTlsConfig::validate() method that ensures client_cert_path and client_key_path are either both set or both empty, throwing std::invalid_argument if misconfiguration is detected. Call validate() in NatsConfig constructors and assignment operators to catch errors at construction time rather than during connect(). Updated applyTlsOptions() to remove duplicate validation check since parity is now guaranteed by constructor validation. Added comprehensive unit tests covering all validation scenarios: - both cert and key set (valid) - both cert and key empty (valid) - cert without key (throws) - key without cert (throws) - copy constructor validation - copy assignment validation Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.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.
Summary
Addresses issue #276 — validate that cert+key are both set or both empty at config time.
Added
NatsTlsConfig::validate()method that ensuresclient_cert_pathandclient_key_pathare either both set or both empty, throwingstd::invalid_argumentif misconfiguration is detected.Validation now occurs in
NatsConfigconstructors and assignment operators to catch errors at construction time rather than duringconnect().Changes
NatsTlsConfig::validate()method with comprehensive validation logic that checks env vars and config fieldsNatsConfigdefault, copy, and move constructors/operators that calltls.validate()applyTlsOptions()to remove duplicate validation check (now guaranteed by constructor)Test Coverage
🤖 Generated with Claude Code