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 s2n-tls client TLS provider #3965

Merged
merged 1 commit into from
Jan 23, 2025

Conversation

goatgoose
Copy link

@goatgoose goatgoose commented Jan 10, 2025

Motivation and Context

Adds s2n-tls as an optional TLS provider to the hyper1 branch.

Related issue: #2446

Description

Currently, smithy-rs clients use rustls as the TLS provider. This PR adds s2n-tls as an optional provider, allowing users to configure smithy-rs to secure their HTTP requests with s2n-tls.

Testing

I added a new client smoke test for s2n-tls. I also added a test that makes sure s2n-tls is actually set as the provider when configured. I was looking for more tests that invoke rustls that I could add an equivalent s2n-tls test for, but was having trouble discovering them. If there are tests that make sense to have please let me know and I will add them!

Some of the CI jobs are still failing. However, they appear to be unrelated to this change. These jobs also failed in the last hyper1 commit:

Also, the canary will need to be run manually if necessary for this change.

Checklist

  • For changes to the smithy-rs codegen or runtime crates, I have created a changelog entry Markdown file in the .changelog directory, specifying "client," "server," or both in the applies_to key.
  • For changes to the AWS SDK, generated SDK code, or SDK runtime crates, I have created a changelog entry Markdown file in the .changelog directory, specifying "aws-sdk-rust" in the applies_to key.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@goatgoose goatgoose marked this pull request as ready for review January 10, 2025 16:42
@goatgoose goatgoose requested a review from a team as a code owner January 10, 2025 16:42
@goatgoose goatgoose marked this pull request as draft January 10, 2025 16:47
Copy link
Contributor

@aajtodd aajtodd left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time to contribute this!

Couple questions/comments but overall looks good.

// TODO(hyper1) s2n support
/// TLS provider based on [s2n-tls](https://github.com/aws/s2n-tls)
#[cfg(feature = "s2n-tls")]
S2ntls,
Copy link
Contributor

Choose a reason for hiding this comment

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

style/naming-bikehsed: Is this the capitalization we want? I realize Rustls is this way but that matches the full name Rustls and the way they refer to it in their own project.

Copy link
Author

@goatgoose goatgoose Jan 13, 2025

Choose a reason for hiding this comment

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

I agree that this capitalization looks strange! I wanted to avoid going against Rust's naming conventions for enums. But if this isn't a concern, something like s2n_tls does look better. I updated the name and ignored the style warning.

Copy link
Author

@goatgoose goatgoose Jan 13, 2025

Choose a reason for hiding this comment

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

There may also be a name that aligns more with the s2n-tls capitalization scheme and doesn't break Rust's naming conventions, like S2nTls maybe. I'll change the name to this for now and I will get more input on the name.

Copy link
Author

Choose a reason for hiding this comment

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

We tentatively agreed on S2nTls with the admission that there isn't really any good way to represent s2n-tls as a Rust enum value. If you have a better alternative please let me know!

rust-runtime/aws-smithy-http-client/src/client/tls.rs Outdated Show resolved Hide resolved
@goatgoose goatgoose marked this pull request as ready for review January 23, 2025 00:15
@goatgoose goatgoose requested a review from aajtodd January 23, 2025 00:16
Copy link
Contributor

@aajtodd aajtodd left a comment

Choose a reason for hiding this comment

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

Thanks for contributing this! Overall looks good.

One question I have is about more advanced TLS configuration (e.g. ca roots, peer verification, etc). I'm wondering if we should define a TlsContext or similar that defines common TLS options we think we could support across providers. Might be useful to have your team's help/input with this.

// S2n,
// TODO(hyper1) s2n support
/// TLS provider based on [s2n-tls](https://github.com/aws/s2n-tls)
#[cfg(feature = "s2n-tls")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to worry about or consider that s2n only works on unix platforms? Should this cfg be gated on both the feature and platform support?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah I considered doing that as well. My concern was someone enabling s2n-tls on a non-unix platform and then trying to figure out why they can't select the s2n-tls provider. A build failure after enabling the feature seemed like it might be less confusing. But maybe this would also be confusing. Let me know what you think, I'm happy to change it!

Copy link
Contributor

Choose a reason for hiding this comment

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

We can leave it for now unless someone else feels strongly at the moment.

@goatgoose
Copy link
Author

I'm wondering if we should define a TlsContext or similar that defines common TLS options we think we could support across providers. Might be useful to have your team's help/input with this.

Yeah we'd be happy to help with that! I believe that our QUIC library, s2n-quic, does something similar. The s2n-tls and rustls client/server s2n-quic builders wrap the underlying s2n-tls and rustls APIs. And both builders share APIs with overlapping functionality, like with_certificate for s2n-tls and rustls. So we might be able to borrow some of that!

@aajtodd aajtodd merged commit 1761488 into smithy-lang:hyper1 Jan 23, 2025
37 of 42 checks passed
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.

2 participants