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

fix: better error for setting bad quic policy #4598

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/usage-guide/topics/ch06-security-policies.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ In contrast, numbered or dated versions are fixed and will never change. The num
* "default_tls13": "20240503"
For previous defaults, see the "Default Policy History" section below.

"default_fips" does not currently support TLS1.3. If you need a policy that supports both FIPS and TLS1.3, choose "20230317". We plan to add TLS1.3 support to both "default" and "default_fips" in the future.

"rfc9151" is derived from [Commercial National Security Algorithm (CNSA) Suite Profile for TLS and DTLS 1.2 and 1.3](https://datatracker.ietf.org/doc/html/rfc9151). This policy restricts the algorithms allowed for signatures on certificates in the certificate chain to RSA or ECDSA with sha384, which may require you to update your certificates.
Like the default policies, this policy may also change if the source RFC definition changes.

Expand Down
25 changes: 25 additions & 0 deletions tests/unit/s2n_quic_support_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,5 +300,30 @@ int main(int argc, char **argv)
EXPECT_SUCCESS(s2n_config_free(config));
};

/* Test: setting policies without TLS1.3 is not allowed when quic is enabled */
{
/* On config */
{
DEFER_CLEANUP(struct s2n_config *config = s2n_config_new(),
s2n_config_ptr_free);
EXPECT_SUCCESS(s2n_config_enable_quic(config));
EXPECT_FAILURE_WITH_ERRNO(
s2n_config_set_cipher_preferences(config, "test_all_tls12"),
S2N_ERR_UNSUPPORTED_WITH_QUIC);
EXPECT_SUCCESS(s2n_config_set_cipher_preferences(config, "test_all_tls13"));
};

/* On connection */
{
DEFER_CLEANUP(struct s2n_connection *conn = s2n_connection_new(S2N_SERVER),
s2n_connection_ptr_free);
EXPECT_SUCCESS(s2n_connection_enable_quic(conn));
EXPECT_FAILURE_WITH_ERRNO(
s2n_connection_set_cipher_preferences(conn, "test_all_tls12"),
S2N_ERR_UNSUPPORTED_WITH_QUIC);
EXPECT_SUCCESS(s2n_connection_set_cipher_preferences(conn, "test_all_tls13"));
};
};

END_TEST();
}
10 changes: 10 additions & 0 deletions tls/s2n_security_policies.c
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,11 @@ int s2n_config_set_cipher_preferences(struct s2n_config *config, const char *ver
/* If the security policy's minimum version is higher than what libcrypto supports, return an error. */
POSIX_ENSURE((security_policy->minimum_protocol_version <= s2n_get_highest_fully_supported_tls_version()), S2N_ERR_PROTOCOL_VERSION_UNSUPPORTED);

/* If the security policy isn't compatible with quic settings, return an error */
if (config->quic_enabled) {
POSIX_ENSURE(s2n_security_policy_supports_tls13(security_policy), S2N_ERR_UNSUPPORTED_WITH_QUIC);
}

config->security_policy = security_policy;
return 0;
}
Expand All @@ -1290,6 +1295,11 @@ int s2n_connection_set_cipher_preferences(struct s2n_connection *conn, const cha
* policy's certificate preferences, return an error. */
POSIX_GUARD_RESULT(s2n_config_validate_loaded_certificates(conn->config, security_policy));

/* If the security policy isn't compatible with quic settings, return an error */
if (s2n_connection_is_quic_enabled(conn)) {
POSIX_ENSURE(s2n_security_policy_supports_tls13(security_policy), S2N_ERR_UNSUPPORTED_WITH_QUIC);
}

conn->security_policy_override = security_policy;
return 0;
}
Expand Down
Loading