@@ -1199,44 +1199,27 @@ static int s_verify_good_host_mqtt_connect(
1199
1199
1200
1200
ASSERT_SUCCESS (s_tls_common_tester_init (allocator , & c_tester ));
1201
1201
1202
- /* ****** NEW ********/
1203
1202
uint8_t outgoing_received_message [128 ] = {0 };
1204
1203
1205
- // const uint8_t mqtt_connect_message[] = {
1206
-
1207
- // 0x10, /* connect */
1208
- // 0x10,/*packet length */
1209
- // 0x00, 0x04,/* protocol name length */
1210
- // 0x4d, 0x51, 0x54, 0x54,/* MQTT */
1211
- // 0x04,/* protocol version 4 (3.11) */
1212
- // 0x02,/* connect flags */
1213
- // 0x00, 0x3c,/* keep alive */
1214
- // 0x00, 0x04, 't', 'e', 's', 't' /* client id(size (2) + data(4) */
1215
- //};
1216
-
1217
- const uint8_t mqtt_connect_message [] = {
1218
- 0x10 , 0x51 , 0x00 , 0x04 , 0x4D , 0x51 , 0x54 , 0x54 , 0x04 , 0x80 , 0x03 , 0xE8 , 0x00 , 0x29 , 0x74 , 0x65 , 0x73 ,
1219
- 0x74 , 0x2D , 0x30 , 0x62 , 0x34 , 0x37 , 0x36 , 0x30 , 0x64 , 0x35 , 0x2D , 0x62 , 0x61 , 0x39 , 0x63 , 0x2D , 0x38 ,
1220
- 0x65 , 0x66 , 0x64 , 0x2D , 0x33 , 0x32 , 0x65 , 0x37 , 0x2D , 0x34 , 0x38 , 0x64 , 0x30 , 0x35 , 0x62 , 0x62 , 0x32 ,
1221
- 0x30 , 0x30 , 0x65 , 0x61 , 0x00 , 0x1A , 0x3F , 0x53 , 0x44 , 0x4B , 0x3D , 0x43 , 0x50 , 0x50 , 0x76 , 0x32 , 0x26 ,
1222
- 0x56 , 0x65 , 0x72 , 0x73 , 0x69 , 0x6F , 0x6E , 0x3D , 0x76 , 0x31 , 0x2E , 0x33 , 0x32 , 0x2E , 0x36
1223
- };
1224
-
1225
- /*
1226
1204
const uint8_t mqtt_connect_message [] = {
1227
- 0x10, 0x51, 0x00, 0x04, 0x4D, 0x51, 0x54, 0x54, 0x04, 0x80,
1228
- 0x03, 0xE8, 0x00, 0x29, 0x74, 0x65, 0x73, 0x74, 0x2D, 0x35,
1229
- 0x62, 0x39, 0x39, 0x36, 0x61, 0x62, 0x63, 0x2D, 0x63, 0x30,
1230
- 0x38, 0x31, 0x2D, 0x37, 0x36, 0x31, 0x37, 0x2D, 0x64, 0x31,
1231
- 0x34, 0x33, 0x2D, 0x64, 0x33, 0x35, 0x66, 0x37, 0x32, 0x65,
1232
- 0x37, 0x36, 0x39, 0x64, 0x62, 0x00, 0x1A, 0x3F, 0x53, 0x44,
1233
- 0x4B, 0x3D, 0x43, 0x50, 0x50, 0x76, 0x32, 0x26, 0x56, 0x65,
1234
- 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x76, 0x31, 0x2E, 0x33,
1235
- 0x32, 0x2E, 0x36, 0x00
1205
+ 0x10 , /* connect packet */
1206
+ 0x51 , /* packet length */
1207
+ 0x00 , 0x04 , /* protocol name length */
1208
+ 0x4D , 0x51 , 0x54 , 0x54 , /* M Q T T */
1209
+ 0x04 , /* protocol version 3.11 = 4 */
1210
+ 0x82 , /* connect flags user name + clean session */
1211
+ 0x03 , 0xE8 , // keep alive
1212
+ 0x00 , 0x29 , /* client id size */
1213
+ 0x74 , 0x65 , 0x73 , 0x74 , 0x2D , 0x30 , 0x62 , 0x34 , 0x37 , 0x36 ,
1214
+ 0x30 , 0x64 , 0x35 , 0x2D , 0x62 , 0x61 , 0x39 , 0x63 , 0x2D , 0x38 ,
1215
+ 0x65 , 0x66 , 0x64 , 0x2D , 0x33 , 0x32 , 0x65 , 0x37 , 0x2D , 0x34 ,
1216
+ 0x38 , 0x64 , 0x30 , 0x35 , 0x62 , 0x62 , 0x32 , 0x30 , 0x30 , 0x65 ,
1217
+ 0x61 , /* client id */
1218
+ 0x00 , 0x1A , /* user name length */
1219
+ 0x3F , 0x53 , 0x44 , 0x4B , 0x3D , 0x43 , 0x50 , 0x50 , 0x76 , 0x32 ,
1220
+ 0x26 , 0x56 , 0x65 , 0x72 , 0x73 , 0x69 , 0x6F , 0x6E , 0x3D , 0x76 ,
1221
+ 0x31 , 0x2E , 0x33 , 0x32 , 0x2E , 0x36 /* user name */
1236
1222
};
1237
- */
1238
-
1239
- // const uint8_t mqtt_connect_message[] = {'a', 'l', 'f', 'r', 'e', 'd', 0x00, 0x02, 0x01};
1240
1223
1241
1224
struct aws_byte_buf write_tag = aws_byte_buf_from_array ((const char * )mqtt_connect_message , 83 );
1242
1225
@@ -1251,8 +1234,6 @@ static int s_verify_good_host_mqtt_connect(
1251
1234
true, write_tag .len , & outgoing_rw_args );
1252
1235
ASSERT_NOT_NULL (outgoing_rw_handler );
1253
1236
1254
- /* end new */
1255
-
1256
1237
struct tls_test_args outgoing_args = {
1257
1238
.mutex = & c_tester .mutex ,
1258
1239
.allocator = allocator ,
@@ -1283,18 +1264,14 @@ static int s_verify_good_host_mqtt_connect(
1283
1264
aws_tls_connection_options_set_callbacks (
1284
1265
& tls_client_conn_options , s_tls_on_negotiated , NULL , NULL , & outgoing_args );
1285
1266
1286
- /* ***** new ****** */
1287
1267
struct aws_byte_buf cert_buf = {0 };
1288
1268
struct aws_byte_buf key_buf = {0 };
1289
1269
struct aws_byte_buf ca_buf = {0 };
1290
1270
struct aws_tls_ctx_options tls_options = {0 };
1291
- ASSERT_SUCCESS (aws_byte_buf_init_from_file (& cert_buf , allocator , "ed384_server.pem" ));
1292
- ASSERT_SUCCESS (aws_byte_buf_init_from_file (& key_buf , allocator , "ed384_key.pem" ));
1293
- ASSERT_SUCCESS (aws_byte_buf_init_from_file (& ca_buf , allocator , "AmazonRootCA1.pem" ));
1294
1271
1295
- // ASSERT_SUCCESS(aws_byte_buf_init_from_file(&cert_buf, allocator, "server_EC384 .pem"));
1296
- // ASSERT_SUCCESS(aws_byte_buf_init_from_file(&key_buf, allocator, "server_EC384.key "));
1297
- // ASSERT_SUCCESS(aws_byte_buf_init_from_file(&ca_buf, allocator, "ca .pem"));
1272
+ ASSERT_SUCCESS (aws_byte_buf_init_from_file (& cert_buf , allocator , "ed384_server .pem" ));
1273
+ ASSERT_SUCCESS (aws_byte_buf_init_from_file (& key_buf , allocator , "ed384_key.pem " ));
1274
+ ASSERT_SUCCESS (aws_byte_buf_init_from_file (& ca_buf , allocator , "AmazonRootCA1 .pem" ));
1298
1275
1299
1276
struct aws_byte_cursor cert_cur = aws_byte_cursor_from_buf (& cert_buf );
1300
1277
struct aws_byte_cursor key_cur = aws_byte_cursor_from_buf (& key_buf );
@@ -1307,10 +1284,7 @@ static int s_verify_good_host_mqtt_connect(
1307
1284
1308
1285
struct aws_tls_ctx * tls_context = aws_tls_client_ctx_new (allocator , & tls_options );
1309
1286
ASSERT_NOT_NULL (tls_context );
1310
- /* new */
1311
1287
tls_client_conn_options .ctx = tls_context ;
1312
- /* new */
1313
- /* ***** new ****** */
1314
1288
1315
1289
struct aws_byte_cursor host_name_cur = aws_byte_cursor_from_string (host_name );
1316
1290
aws_tls_connection_options_set_server_name (& tls_client_conn_options , allocator , & host_name_cur );
@@ -1354,8 +1328,6 @@ static int s_verify_good_host_mqtt_connect(
1354
1328
ASSERT_FALSE (outgoing_args .error_invoked );
1355
1329
struct aws_byte_buf expected_protocol = aws_byte_buf_from_c_str ("x-amzn-mqtt-ca" );
1356
1330
/* check ALPN and SNI was properly negotiated */
1357
-
1358
-
1359
1331
if (aws_tls_is_alpn_available () && client_ctx_options .verify_peer ) {
1360
1332
ASSERT_BIN_ARRAYS_EQUALS (
1361
1333
expected_protocol .buffer ,
@@ -1364,19 +1336,12 @@ static int s_verify_good_host_mqtt_connect(
1364
1336
outgoing_args .negotiated_protocol .len );
1365
1337
}
1366
1338
1339
+ ASSERT_BIN_ARRAYS_EQUALS (
1340
+ host_name -> bytes , host_name -> len , outgoing_args .server_name .buffer , outgoing_args .server_name .len );
1367
1341
1368
- // ASSERT_BIN_ARRAYS_EQUALS(
1369
- // host_name->bytes, host_name->len, outgoing_args.server_name.buffer, outgoing_args.server_name.len);
1370
-
1371
-
1372
- /* XXX: ---- new ----*/
1373
1342
/* Do the IO operations */
1374
- printf (" ============================================= doing the io operaion \n" );
1375
1343
outgoing_rw_args .invocation_happened = false;
1376
1344
rw_handler_write (outgoing_args .rw_handler , outgoing_args .rw_slot , & write_tag );
1377
-
1378
-
1379
- printf (" ============================================= waiting to read data \n" );
1380
1345
ASSERT_SUCCESS (aws_mutex_lock (& c_tester .mutex ));
1381
1346
1382
1347
ASSERT_SUCCESS (aws_condition_variable_wait_pred (
@@ -1386,36 +1351,13 @@ static int s_verify_good_host_mqtt_connect(
1386
1351
ASSERT_SUCCESS (aws_mutex_unlock (& c_tester .mutex ));
1387
1352
1388
1353
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" );
1394
- //printf("conn ack is %d\n", outgoing_rw_args.received_message.buffer[3]);
1395
1354
1396
1355
ASSERT_INT_EQUALS (0x20 , outgoing_rw_args .received_message .buffer [0 ]); /* conn ack */
1397
- ASSERT_INT_EQUALS (0x02 , outgoing_rw_args .received_message .buffer [1 ]); /* conn ack */
1398
- ASSERT_INT_EQUALS (0x01 , outgoing_rw_args .received_message .buffer [2 ]); /* conn ack */
1399
- ASSERT_INT_EQUALS (0x00 , outgoing_rw_args .received_message .buffer [3 ]); /* conn ack */
1356
+ ASSERT_INT_EQUALS (0x02 , outgoing_rw_args .received_message .buffer [1 ]);
1357
+ ASSERT_INT_EQUALS (0x00 , outgoing_rw_args .received_message .buffer [2 ]); /* clean session */
1358
+ ASSERT_INT_EQUALS (0x00 , outgoing_rw_args .received_message .buffer [3 ]);
1400
1359
aws_mutex_unlock (outgoing_rw_args .mutex );
1401
1360
1402
- //ASSERT_INT_EQUALS('0', outgoing_rw_args.received_message.buffer[0]); /* conn ack */
1403
- //ASSERT_INT_EQUALS('0', outgoing_rw_args.received_message.buffer[1]); /* conn ack */
1404
- //ASSERT_INT_EQUALS('0', outgoing_rw_args.received_message.buffer[2]); /* conn ack */
1405
- printf (" ============================================= data read\n" );
1406
-
1407
- //outgoing_rw_args.invocation_happened = false;
1408
- //ASSERT_INT_EQUALS(1, outgoing_rw_args.read_invocations);
1409
-
1410
- /*
1411
- struct aws_byte_cursor cert_cur = aws_byte_cursor_from_buf(&cert_buf);
1412
- struct aws_byte_cursor key_cur = aws_byte_cursor_from_buf(&key_buf);
1413
- struct aws_byte_cursor ca_cur = aws_byte_cursor_from_buf(&ca_buf);
1414
- */
1415
- /* ---- */
1416
-
1417
- printf (" ======================================================= freeing memory\n" );
1418
-
1419
1361
ASSERT_SUCCESS (aws_mutex_lock (& c_tester .mutex ));
1420
1362
aws_channel_shutdown (outgoing_args .channel , AWS_OP_SUCCESS );
1421
1363
ASSERT_SUCCESS (aws_condition_variable_wait_pred (
@@ -1428,7 +1370,6 @@ static int s_verify_good_host_mqtt_connect(
1428
1370
aws_tls_ctx_release (client_ctx );
1429
1371
aws_tls_ctx_release (client_ctx );
1430
1372
aws_tls_ctx_release (tls_context -> impl );
1431
- //aws_tls_ctx_release(tls_context->impl);
1432
1373
1433
1374
aws_tls_ctx_options_clean_up (& tls_options );
1434
1375
@@ -1465,15 +1406,10 @@ static int s_tls_client_channel_negotiation_success_ecc384_fn(struct aws_allocat
1465
1406
}
1466
1407
1467
1408
AWS_TEST_CASE (tls_client_channel_negotiation_success_ecc384 , s_tls_client_channel_negotiation_success_ecc384_fn )
1468
-
1469
- //AWS_STATIC_STRING_FROM_LITERAL(s_aws_ecc384_host_name, "a2w1wmp9234lcw-ats.iot.us-west-2.amazonaws.com");
1470
- //AWS_STATIC_STRING_FROM_LITERAL(s_aws_ecc384_host_name, "192.168.1.152"); /* mosuquitto/openssl local server */
1471
1409
AWS_STATIC_STRING_FROM_LITERAL (s_aws_ecc384_host_name , "a2yvr5l8sc9814-ats.iot.us-east-2.amazonaws.com" );
1472
- //AWS_STATIC_STRING_FROM_LITERAL(s_aws_ecc384_host_name, "172.17.48.219"); /* s2n windows wsl */
1473
1410
1474
1411
static int s_tls_client_channel_negotiation_success_ecc384_tls1_3_fn (struct aws_allocator * allocator , void * ctx ) {
1475
1412
(void )ctx ;
1476
- //return s_verify_good_host_mqtt_connect(allocator, s_aws_ecc384_host_name, 8883, NULL);
1477
1413
return s_verify_good_host_mqtt_connect (allocator , s_aws_ecc384_host_name , 443 , NULL );
1478
1414
}
1479
1415
0 commit comments