Skip to content

Commit ae0a0bc

Browse files
committed
add alpn protocol
1 parent f25eda6 commit ae0a0bc

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

tests/tls_handler_test.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ static int s_verify_good_host_mqtt_connect(
12691269
AWS_ZERO_STRUCT(client_ctx_options);
12701270
aws_tls_ctx_options_set_verify_peer(&client_ctx_options, true);
12711271
aws_tls_ctx_options_init_default_client(&client_ctx_options, allocator);
1272-
//aws_tls_ctx_options_set_alpn_list(&client_ctx_options, "mqtt");
1272+
aws_tls_ctx_options_set_alpn_list(&client_ctx_options, "x-amzn-mqtt-ca");
12731273

12741274
if (override_tls_options_fn) {
12751275
(*override_tls_options_fn)(&client_ctx_options);
@@ -1314,7 +1314,7 @@ static int s_verify_good_host_mqtt_connect(
13141314

13151315
struct aws_byte_cursor host_name_cur = aws_byte_cursor_from_string(host_name);
13161316
aws_tls_connection_options_set_server_name(&tls_client_conn_options, allocator, &host_name_cur);
1317-
//aws_tls_connection_options_set_alpn_list(&tls_client_conn_options, allocator, "mqtt");
1317+
aws_tls_connection_options_set_alpn_list(&tls_client_conn_options, allocator, "x-amzn-mqtt-ca");
13181318

13191319
struct aws_socket_options options;
13201320
AWS_ZERO_STRUCT(options);
@@ -1352,18 +1352,18 @@ static int s_verify_good_host_mqtt_connect(
13521352
ASSERT_SUCCESS(aws_mutex_unlock(&c_tester.mutex));
13531353

13541354
ASSERT_FALSE(outgoing_args.error_invoked);
1355-
//struct aws_byte_buf expected_protocol = aws_byte_buf_from_c_str("http/1.1");
1355+
struct aws_byte_buf expected_protocol = aws_byte_buf_from_c_str("x-amzn-mqtt-ca");
13561356
/* check ALPN and SNI was properly negotiated */
13571357

1358-
/*
1358+
13591359
if (aws_tls_is_alpn_available() && client_ctx_options.verify_peer) {
13601360
ASSERT_BIN_ARRAYS_EQUALS(
13611361
expected_protocol.buffer,
13621362
expected_protocol.len,
13631363
outgoing_args.negotiated_protocol.buffer,
13641364
outgoing_args.negotiated_protocol.len);
13651365
}
1366-
*/
1366+
13671367

13681368
// ASSERT_BIN_ARRAYS_EQUALS(
13691369
// host_name->bytes, host_name->len, outgoing_args.server_name.buffer, outgoing_args.server_name.len);
@@ -1383,19 +1383,21 @@ static int s_verify_good_host_mqtt_connect(
13831383
&c_tester.condition_variable, &c_tester.mutex,
13841384
s_tls_test_read_predicate, &outgoing_rw_args));
13851385

1386-
13871386
ASSERT_SUCCESS(aws_mutex_unlock(&c_tester.mutex));
13881387

1389-
//printf("=====================================printing message received message buffer\n");
1390-
//for (size_t i = 0; i < outgoing_rw_args.received_message.len; i++) {
1391-
// printf(" %.2X ", outgoing_rw_args.received_message.buffer[i]);
1392-
// }
1393-
// printf("\n");
1388+
aws_mutex_lock(outgoing_rw_args.mutex);
1389+
printf("=====================================printing message received message buffer\n");
1390+
for (size_t i = 0; i < outgoing_rw_args.received_message.len; i++) {
1391+
printf(" %.2X ", outgoing_rw_args.received_message.buffer[i]);
1392+
}
1393+
printf("\n");
13941394
//printf("conn ack is %d\n", outgoing_rw_args.received_message.buffer[3]);
1395+
13951396
ASSERT_INT_EQUALS(0x20, outgoing_rw_args.received_message.buffer[0]); /* conn ack */
13961397
ASSERT_INT_EQUALS(0x02, outgoing_rw_args.received_message.buffer[1]); /* conn ack */
13971398
ASSERT_INT_EQUALS(0x01, outgoing_rw_args.received_message.buffer[2]); /* conn ack */
13981399
ASSERT_INT_EQUALS(0x00, outgoing_rw_args.received_message.buffer[3]); /* conn ack */
1400+
aws_mutex_unlock(outgoing_rw_args.mutex);
13991401

14001402
//ASSERT_INT_EQUALS('0', outgoing_rw_args.received_message.buffer[0]); /* conn ack */
14011403
//ASSERT_INT_EQUALS('0', outgoing_rw_args.received_message.buffer[1]); /* conn ack */
@@ -1471,7 +1473,8 @@ AWS_STATIC_STRING_FROM_LITERAL(s_aws_ecc384_host_name, "a2yvr5l8sc9814-ats.iot.u
14711473

14721474
static int s_tls_client_channel_negotiation_success_ecc384_tls1_3_fn(struct aws_allocator *allocator, void *ctx) {
14731475
(void)ctx;
1474-
return s_verify_good_host_mqtt_connect(allocator, s_aws_ecc384_host_name, 8883, NULL);
1476+
//return s_verify_good_host_mqtt_connect(allocator, s_aws_ecc384_host_name, 8883, NULL);
1477+
return s_verify_good_host_mqtt_connect(allocator, s_aws_ecc384_host_name, 443, NULL);
14751478
}
14761479

14771480
AWS_TEST_CASE(

0 commit comments

Comments
 (0)