Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TSIG middleware. #380

Merged
merged 154 commits into from
Sep 16, 2024
Merged

Add TSIG middleware. #380

merged 154 commits into from
Sep 16, 2024

Conversation

ximon18
Copy link
Member

@ximon18 ximon18 commented Sep 3, 2024

Taken from the xfr branch in order to split PR #335 into several smaller PRs.

Notable changes:

  • Add TSIG response signing middleware.
  • Add TSIG Stelline test recipe.
  • Update Stelline server integration tests to use the new TSIG middleware.
  • Remove unnecessary Unpin bounds in net::server::message::Request.
  • Tsig module changes:
    • Derive Clone for Key.
    • Added Key::compose_len() for determining how many response bytes to reserve.
    • Added From<ServerTransaction<K>> for ServerSequence<K>.
    • Various minor RustDoc improvements.
    • Made tsig::ServerError::unsigned() public.
  • Make Time48 obey mock (predictable and controllable) time so that TSIG signing uses mock time during Stelline tests.
  • Don't set the AA flag on test service responses as (a) actual zone serving doesn't do this yet and this still needs fixing, and (b) it violates the expectations of the TSIG Stelline test that verifies at a byte level the TSIG response signature.

This PR will also benefit from merging PR #334 and PR #390.

ximon18 and others added 30 commits August 6, 2024 23:34
…tain number of bytes should be reserved (to make space for post-processing adding EDNS options to the response), and (b) strongly typed passing of arbitrary metadata between middleware that produces a type and middleware that consumes the type (e.g. a TSIG key name).
…o that a wrapper client (such as a future TSIG client) can augment the message before it gets sent.
- Added a simple UDP client that doesn't interfere with requests before sending (for TSIG testing).
- Added support for receiving multiple responses (for XFR testing).
- Added support for connection timeout errors
- Added support for connection termination errors (for EDNS testing).
- Added support for specifying the TSIG key to use (for TSIG testing).
- Added support for $ORIGIN in zone file fragments.
- Simplified rcode checking and use it instead of the yxrrset BADCOOKIE hack.
- In memory channel changes:
  - Fixed a trace message that incorrectly referred to client instead of server.
  - Fixed a too-tight connection read loop that was preventing Tokio task switching.
  - Added connection shutdown detection.
- Fixed incorrect setting of TCP mode to true when UDP mode was requested.
…t' into stelline-server-testing-changes.

Update Stelline based server tests to work with new multiple response capable
Rust types and alternate stream end detection mechanism.
@Philip-NLnetLabs
Copy link
Member

That needs to listed as a limitation. Certainly for UPDATE that is something we need.

…f available, via a new TruncationContext type.

- Truncate for TCP as well as UDP.
- Return ServiceError::InternalError if truncation fails.
- Implement handling of ServiceError in DgramServer and stream::Connection.
- Break DgramServer and stream::Connection dispatch to service code out into helper RequestDispatcher types.
- Terminate the response stream if ServiceError::InternalError occurs.
@ximon18
Copy link
Member Author

ximon18 commented Sep 13, 2024

That needs to listed as a limitation. Certainly for UPDATE that is something we need.

Done.

Copy link
Member Author

@ximon18 ximon18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that for a middleware TSIG layer it is best to reject what we cannot support at the moment. So if get_relevant_question fails then don't proceed.

After some internal discussion it seems to me that there is no reason to restrict the opcode or query type on which TSIG verification is performed. If the request has a TSIG RR and the server stack includes TSIG middleware then that middleware should verify the TSIG signature and also sign any corresponding response. So I'm going to remove this restriction entirely.

ximon18 and others added 4 commits September 16, 2024 13:24
Co-authored-by: Terts Diepraam <terts.diepraam@gmail.com>
Co-authored-by: Terts Diepraam <terts.diepraam@gmail.com>
Co-authored-by: Terts Diepraam <terts.diepraam@gmail.com>
@ximon18 ximon18 merged commit 400843e into main Sep 16, 2024
26 checks passed
@ximon18 ximon18 deleted the tsig-middleware branch September 16, 2024 14:25
ximon18 added a commit that referenced this pull request Oct 3, 2024
- Add TSIG response signing middleware.
- Update Stelline server integration tests to use the new TSIG middleware.
- Add TSIG Stelline test recipe.
- TSIG module changes:
  - Derive Clone for Key.
  - Added Key::compose_len() for determining how many response bytes to reserve.
  - Added ClientTransaction::wrapped_key(), ClientSequence::wrapped_key() and SigningContext::wrapped_key() to access the real underlying "wrapped" key type.
  - Added From<ServerTransaction<K>> for ServerSequence<K>.
  - Various minor RustDoc improvements.
 - Make Time48 obey mock (predictable and controllable) time so that TSIG signing uses mock time during Stelline tests.

Other:
- Remove unnecessary Unpin bounds on net::server::message::Request.
- Remove unnecessary Clone bound on impl SendRequest for net::client::dgram::Connection.
- Remove unnecessary mutex lock on middleware post-processing response state and rename PostprocessingConfig to PostprocessingState to better reflect its mutable nature.
- Don't set the AA flag on test service responses as (a) actual zone serving doesn't do this yet and this still needs fixing, and (b) it violates the expectations of the TSIG Stelline test that verifies at a byte level the TSIG response signature.

---------

Co-authored-by: Philip Homburg <philip@nlnetlabs.nl>
Co-authored-by: Philip-NLnetLabs <93709748+Philip-NLnetLabs@users.noreply.github.com>
Co-authored-by: Terts Diepraam <terts.diepraam@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants