Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

jmayclin
Copy link
Contributor

Description of changes:

Allow connection to be cleanly shutdown through the generic Connection trait.

We take on a slightly larger refactor, splitting the connection traits into a TlsConnection and TlsMetrics trait. This allows abstractions to be a bit more focused on the relevant functionality. It also allows us to better handle the "fuzziness" of a lot of the metrics APIs.

  • TlsConnection: rock solid, everything behaves the same
  • TlsMetrics: fuzzier, with some restrictions.

Testing:

Fixed existing unit tests and manually ran the benchmarks.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions github-actions bot added the s2n-core team label Jul 17, 2025
@jmayclin jmayclin requested review from johubertj, lrstewart and goatgoose and removed request for johubertj July 17, 2025 01:06
@lrstewart lrstewart changed the title feat(bench): add generic shutdown functioanlity feat(bench): add generic shutdown functionality Jul 17, 2025
jmayclin added 3 commits July 18, 2025 06:32
* typo
* rename shutdown methods & document io behavior
* default disable session resumption on servers
* better shutdown error message
* correct comment on NST stuff
* rename trait to TlsInfo
* fix typo
@jmayclin jmayclin requested review from goatgoose and lrstewart July 19, 2025 00:31
Comment on lines 177 to 179
/// This might also read the `CloseNotify` sent by the peer, because most TLS
/// implementations attempt both reading and writing on this method.
fn shutdown(&mut self);
Copy link
Contributor

@lrstewart lrstewart Jul 21, 2025

Choose a reason for hiding this comment

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

Idk, with the behavior so unpredicatable, is it really worth separating this from shutdown_finish? You're even calling the same methods for both shutdown and shutdown_finished for all the implementations.

Would it make more sense to have a single poll_shutdown for each implementation, and then the harness just calls it for the client and server in a loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think no, because there isn't actually a unified poll_shutdown API. While that would work for OpenSSL and s2n-tls, rustls has an explicit "send_close_notify" API, which doesn't fit into the "poll_shutdown" API

        match &mut self.connection {
            Connection::Client(client_connection) => client_connection.send_close_notify(),
            Connection::Server(server_connection) => server_connection.send_close_notify(),
        }

Copy link
Contributor

@lrstewart lrstewart Jul 22, 2025

Choose a reason for hiding this comment

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

Sure, but send_close_notify says:

Does nothing if any close_notify or fatal alert was already sent.

So you could just always call it on poll_shutdown.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, after a bit more research I think I was just a bit confused by the API naming

  • openssl shutdown will only write on the first call
  • rustls complete_io will only write on the first call

So I switched the s2n-tls implementation to use poll_shutdown_send, and everything should now have a unified API with

  • shutdown_send -> only writes
  • shutdown_finish -> only reads.

@jmayclin jmayclin requested a review from maddeleine July 21, 2025 23:59
@jmayclin jmayclin requested a review from maddeleine July 22, 2025 18:31
@jmayclin jmayclin enabled auto-merge (squash) July 22, 2025 18:41
@jmayclin jmayclin merged commit 42a5d6d into aws:main Jul 22, 2025
50 checks passed
@jmayclin jmayclin self-assigned this Jul 24, 2025
johubertj pushed a commit to johubertj/s2n-tls that referenced this pull request Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants