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

test: pin tests to TLS 1.2 policy #4926

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

test: pin tests to TLS 1.2 policy #4926

wants to merge 11 commits into from

Conversation

toidiu
Copy link
Contributor

@toidiu toidiu commented Nov 21, 2024

#4765

Description of changes:

Pinning some tests to a numbered TLS1.2 policy in preparation for default TLS1.3 support.

Testing:

Existing tests should pass.

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

@toidiu toidiu changed the title Ak pin test1 test: pin tests to TLS 1.2 policy Nov 21, 2024
@@ -63,13 +64,15 @@ mod tests {
}

#[test]
fn resume_session() -> Result<(), Box<dyn Error>> {
fn resume_tls12_session() -> Result<(), Box<dyn Error>> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a test named resume_tls13_session below and this one is tls1.2 specific.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TLS1.3 test is done below and explicitly sets the default_tls13 policy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These were mean to only support TLS 1.2. We toggle on fips support to maintain current behavior.

@toidiu toidiu marked this pull request as ready for review November 21, 2024 21:17
@toidiu toidiu marked this pull request as draft November 21, 2024 21:18
@toidiu toidiu marked this pull request as ready for review November 21, 2024 21:36
Comment on lines 87 to 94
let tls12 = handshake_with_domain(domain, "default").await?;
let tls12 = handshake_with_domain(domain, "20240501").await?;
assert_eq!(tls12.as_ref().actual_protocol_version()?, Version::TLS12);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want to test TLS1.2 here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test were not written to work with a fips security policy so this maintains the current behavior by pinning test to "default_tls13".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This tests the following ecc preferences and requires a security policy which supports all of them (aka non-FIPS). Once we switch to TLS1.3 by default, it will be possible to use a FIPS TLS1.3 policy by default, which breaks this test.

  • p256
  • x25519 (not supported with a FIPS security policy)
  • p384

@lrstewart lrstewart self-requested a review November 22, 2024 00:10
Comment on lines 111 to 113
pub(crate) const TESTING_TLS12: Policy = policy!("20240501");

Copy link
Contributor

Choose a reason for hiding this comment

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

Adding this didn't help as much as I thought it would :/ You've still got the integration tests and the tokio tests using the magic number. Maybe a pub policy is worth it.

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 we should think hard before exposing more "default" policies, especially from the Rust bindings. For the moment, I have created a TESTING_TLS12 policy gated to the unstable-testing feature. I consider this a 2-way decision so we can always change it if we need.

Comment on lines +263 to +266
DEFER_CLEANUP(struct s2n_config *config = s2n_config_new(),
s2n_config_ptr_free);
EXPECT_NOT_NULL(config);
EXPECT_SUCCESS(s2n_config_set_cipher_preferences(config, "default_tls13"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Why bother creating a config? Couldn't you just use s2n_connection_set_cipher_preferences?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

s2n_connection_set_cipher_preferences doesnt work.

s2n_connection_set_cipher_preferences sets the conn->security_policy_override field but it get overridden by this test which is also directly modifying the field.

Comment on lines 118 to 119
DEFAULT_TLS13,
TESTING_TLS12,
Copy link
Contributor

Choose a reason for hiding this comment

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

Rust doesn't get mad at you for putting a non-pub struct in a pub list?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope. I couldn't find docs but experimenting showed that its essentially ok to pub export a pub(crate). It does complain if its "private" i.e. not-pub

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