-
Notifications
You must be signed in to change notification settings - Fork 200
Fix grpc-master-x86_64 integration test
#3346
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2028,6 +2028,31 @@ int SSL_set1_groups(SSL *ssl, const int *groups, size_t num_groups) { | |||||||||||||||
| MakeConstSpan(groups, num_groups)); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| static bool ssl_check_group_ids(Array<uint16_t> *out_group_ids, | ||||||||||||||||
| Span<const uint16_t> group_ids) { | ||||||||||||||||
| for (uint16_t group_id : group_ids) { | ||||||||||||||||
| if (ssl_group_id_to_nid(group_id) == NID_undef) { | ||||||||||||||||
| return false; | ||||||||||||||||
| } | ||||||||||||||||
|
Comment on lines
+2034
to
+2036
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BoringSSL's equivalent ( Suggest matching upstream:
Suggested change
|
||||||||||||||||
| } | ||||||||||||||||
| return out_group_ids->CopyFrom(group_ids); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| int SSL_CTX_set1_group_ids(SSL_CTX *ctx, const uint16_t *group_ids, | ||||||||||||||||
| size_t num_group_ids) { | ||||||||||||||||
| return ssl_check_group_ids(&ctx->supported_group_list, | ||||||||||||||||
| MakeConstSpan(group_ids, num_group_ids)); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| int SSL_set1_group_ids(SSL *ssl, const uint16_t *group_ids, | ||||||||||||||||
| size_t num_group_ids) { | ||||||||||||||||
| if (!ssl->config) { | ||||||||||||||||
| return 0; | ||||||||||||||||
| } | ||||||||||||||||
| return ssl_check_group_ids(&ssl->config->supported_group_list, | ||||||||||||||||
| MakeConstSpan(group_ids, num_group_ids)); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| static bool ssl_str_to_group_ids(Array<uint16_t> *out_group_ids, | ||||||||||||||||
| const char *str) { | ||||||||||||||||
| // Count the number of groups in the list. | ||||||||||||||||
|
|
||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -832,6 +832,51 @@ TEST(SSLTest, EarlyCallbackVersionSwitch) { | |
| EXPECT_EQ(TLS1_2_VERSION, SSL_version(client.get())); | ||
| } | ||
|
|
||
| // Test that the handshake succeeds when the early callback leaves stale errors | ||
| // on the error queue | ||
| TEST(SSLTest, EarlyCallbackStaleErrorOnQueue) { | ||
| bssl::UniquePtr<SSL_CTX> server_ctx = | ||
| CreateContextWithTestCertificate(TLS_method()); | ||
| bssl::UniquePtr<SSL_CTX> client_ctx(SSL_CTX_new(TLS_method())); | ||
| ASSERT_TRUE(server_ctx); | ||
| ASSERT_TRUE(client_ctx); | ||
|
|
||
| SSL_CTX_set_select_certificate_cb( | ||
| server_ctx.get(), | ||
| [](const SSL_CLIENT_HELLO *) -> ssl_select_cert_result_t { | ||
| // Simulate a PEM parsing loop leaving a stale error on the queue. | ||
| OPENSSL_PUT_ERROR(PEM, PEM_R_NO_START_LINE); | ||
| return ssl_select_cert_success; | ||
| }); | ||
|
|
||
| bssl::UniquePtr<SSL> client, server; | ||
| ASSERT_TRUE(ConnectClientAndServer(&client, &server, client_ctx.get(), | ||
| server_ctx.get())); | ||
| } | ||
|
|
||
| TEST(SSLTest, Set1GroupIds) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Couple of small things:
|
||
| bssl::UniquePtr<SSL_CTX> ctx(SSL_CTX_new(TLS_method())); | ||
| ASSERT_TRUE(ctx); | ||
| bssl::UniquePtr<SSL> ssl(SSL_new(ctx.get())); | ||
| ASSERT_TRUE(ssl); | ||
|
|
||
| // Valid group IDs should succeed. | ||
| const uint16_t valid_groups[] = {SSL_GROUP_X25519, SSL_GROUP_SECP256R1, | ||
| SSL_GROUP_SECP384R1}; | ||
| EXPECT_TRUE(SSL_CTX_set1_group_ids(ctx.get(), valid_groups, 3)); | ||
| EXPECT_TRUE(SSL_set1_group_ids(ssl.get(), valid_groups, 3)); | ||
|
|
||
| // A single valid group ID should succeed. | ||
| const uint16_t one_group[] = {SSL_GROUP_X25519}; | ||
| EXPECT_TRUE(SSL_CTX_set1_group_ids(ctx.get(), one_group, 1)); | ||
| EXPECT_TRUE(SSL_set1_group_ids(ssl.get(), one_group, 1)); | ||
|
|
||
| // Invalid group IDs should fail. | ||
| const uint16_t invalid_groups[] = {0xFFFF}; | ||
| EXPECT_FALSE(SSL_CTX_set1_group_ids(ctx.get(), invalid_groups, 1)); | ||
| EXPECT_FALSE(SSL_set1_group_ids(ssl.get(), invalid_groups, 1)); | ||
| } | ||
|
|
||
| TEST(SSLTest, SetVersion) { | ||
| bssl::UniquePtr<SSL_CTX> ctx(SSL_CTX_new(TLS_method())); | ||
| ASSERT_TRUE(ctx); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NP: BoringSSL also rejects duplicate group IDs here (
check_no_duplicates). Duplicates would just get advertised twice insupported_groups, so probably harmless, but worth a decision.