diff options
| author | Wenhui Xie <[email protected]> | 2023-12-26 12:57:29 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-12-26 12:57:29 +0800 |
| commit | fceacf6fc04abd72472c3f6cb86c4d469fb4a734 (patch) | |
| tree | 56b10ea98f4827fb7a1146f46f57d74968e6fffb | |
| parent | 050f07ba7e09f7c04acf73887f40fef938ae9971 (diff) | |
Add MQTT interoperability test. (#223)
44 files changed, 4206 insertions, 2 deletions
diff --git a/.github/workflows/regression_test.yml b/.github/workflows/regression_test.yml index e694f838..beec3a8f 100644 --- a/.github/workflows/regression_test.yml +++ b/.github/workflows/regression_test.yml @@ -174,6 +174,22 @@ jobs: cmake_path: ./test/cmake/nx_secure_interoperability result_affix: Secure_Interoperability skip_deploy: true + MQTT_Interoperability: + permissions: + contents: read + issues: read + checks: write + pull-requests: write + pages: write + id-token: write + uses: azure-rtos/threadx/.github/workflows/regression_template.yml@master + with: + install_script: ./scripts/install_mqtt.sh + build_script: ./scripts/build_mqtt_interoperability.sh + test_script: ./scripts/test_mqtt_interoperability.sh + cmake_path: ./test/cmake/mqtt_interoperability + result_affix: MQTT_Interoperability + skip_deploy: true Deploy: permissions: contents: read @@ -182,8 +198,8 @@ jobs: pull-requests: write pages: write id-token: write - needs: [NetXDuo, Web, MQTT, NetXDuo64, NetXDuo_Fast, Azure_IoT, Secure, Crypto, Secure_Interoperability] + needs: [NetXDuo, Web, MQTT, NetXDuo64, NetXDuo_Fast, Azure_IoT, Secure, Crypto, Secure_Interoperability, MQTT_Interoperability] uses: azure-rtos/threadx/.github/workflows/regression_template.yml@master with: skip_test: true - deploy_list: "NetXDuo Web MQTT NetXDuo64 NetXDuo_Fast Azure_IoT Secure Crypto Secure_Interoperability"
\ No newline at end of file + deploy_list: "NetXDuo Web MQTT NetXDuo64 NetXDuo_Fast Azure_IoT Secure Crypto Secure_Interoperability MQTT_Interoperability"
\ No newline at end of file diff --git a/scripts/build_mqtt_interoperability.sh b/scripts/build_mqtt_interoperability.sh new file mode 100755 index 00000000..573c8e6d --- /dev/null +++ b/scripts/build_mqtt_interoperability.sh @@ -0,0 +1,3 @@ +#! /bin/bash + +$(dirname `realpath $0`)/../test/cmake/mqtt_interoperability/run.sh build all diff --git a/scripts/install_mqtt.sh b/scripts/install_mqtt.sh new file mode 100755 index 00000000..41824416 --- /dev/null +++ b/scripts/install_mqtt.sh @@ -0,0 +1,17 @@ +#! /bin/bash + +sudo dpkg --add-architecture i386 + +sudo apt update +sudo apt install -y \ + gcc-multilib \ + g++ \ + python3-pip \ + ninja-build \ + unifdef \ + dos2unix \ + gcovr \ + libpcap-dev:i386 libgcc-s1:i386 \ + ethtool \ + mosquitto \ + mosquitto-clients
\ No newline at end of file diff --git a/scripts/test_mqtt_interoperability.sh b/scripts/test_mqtt_interoperability.sh new file mode 100755 index 00000000..b3dac54d --- /dev/null +++ b/scripts/test_mqtt_interoperability.sh @@ -0,0 +1,3 @@ +#! /bin/bash + +sudo CTEST_PARALLEL_LEVEL=1 $(dirname `realpath $0`)/../test/cmake/mqtt_interoperability/run.sh test all diff --git a/test/cmake/mqtt_interoperability/CMakeLists.txt b/test/cmake/mqtt_interoperability/CMakeLists.txt new file mode 120000 index 00000000..bc5e379c --- /dev/null +++ b/test/cmake/mqtt_interoperability/CMakeLists.txt @@ -0,0 +1 @@ +../mqtt/CMakeLists.txt
\ No newline at end of file diff --git a/test/cmake/mqtt_interoperability/coverage.sh b/test/cmake/mqtt_interoperability/coverage.sh new file mode 120000 index 00000000..8474953c --- /dev/null +++ b/test/cmake/mqtt_interoperability/coverage.sh @@ -0,0 +1 @@ +../mqtt/coverage.sh
\ No newline at end of file diff --git a/test/cmake/mqtt_interoperability/libs b/test/cmake/mqtt_interoperability/libs new file mode 120000 index 00000000..d4bda9b4 --- /dev/null +++ b/test/cmake/mqtt_interoperability/libs @@ -0,0 +1 @@ +../libs
\ No newline at end of file diff --git a/test/cmake/mqtt_interoperability/regression/CMakeLists.txt b/test/cmake/mqtt_interoperability/regression/CMakeLists.txt new file mode 100644 index 00000000..c653fded --- /dev/null +++ b/test/cmake/mqtt_interoperability/regression/CMakeLists.txt @@ -0,0 +1,120 @@ +cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR) +cmake_policy(SET CMP0057 NEW) + +project(regression_test LANGUAGES C) + +get_filename_component( + SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/../../../regression/interoperability_test/mqtt_test + ABSOLUTE) + +if(NOT "-DNXD_MQTT_REQUIRE_TLS" IN_LIST ${CMAKE_BUILD_TYPE}) + list(APPEND mqtt_test_cases mqtt_subscriber_test) + set(mqtt_subscriber_test_file_list + ${SOURCE_DIR}/linux_mqtt_subscriber_test_entry.c + ${SOURCE_DIR}/linux_mqtt_subscriber_test_server.c + ${SOURCE_DIR}/linux_mqtt_subscriber_test_publisher.c + ${SOURCE_DIR}/netx_mqtt_subscriber_test.c) + list(APPEND mqtt_test_cases mqtt_subscriber_empty_message_test) + set(mqtt_subscriber_empty_message_test_file_list + ${SOURCE_DIR}/linux_mqtt_subscriber_test_entry.c + ${SOURCE_DIR}/linux_mqtt_subscriber_test_server.c + ${SOURCE_DIR}/linux_mqtt_subscriber_empty_message_test_publisher.c + ${SOURCE_DIR}/netx_mqtt_subscriber_empty_message_test.c) +endif() + +if("-DNX_SECURE_ENABLE" IN_LIST ${CMAKE_BUILD_TYPE}) + list(APPEND mqtt_test_cases mqtt_tls_subscriber_twice_test) + set(mqtt_tls_subscriber_twice_test_file_list + ${SOURCE_DIR}/linux_mqtt_tls_subscriber_test_entry.c + ${SOURCE_DIR}/linux_mqtt_tls_subscriber_test_server.c + ${SOURCE_DIR}/linux_mqtt_tls_subscriber_twice_test_publisher.c + ${SOURCE_DIR}/netx_mqtt_tls_subscriber_twice_test.c) + + list(APPEND mqtt_test_cases mqtt_double_subscribers_test) + set(mqtt_double_subscribers_test_file_list + ${SOURCE_DIR}/linux_mqtt_tls_subscriber_test_entry.c + ${SOURCE_DIR}/linux_mqtt_tls_subscriber_test_server.c + ${SOURCE_DIR}/linux_mqtt_tls_subscriber_test_publisher.c + ${SOURCE_DIR}/netx_mqtt_double_subscribers_test.c) + + list(APPEND mqtt_test_cases mqtt_tls_subscriber_test) + set(mqtt_tls_subscriber_test_file_list + ${SOURCE_DIR}/linux_mqtt_tls_subscriber_test_entry.c + ${SOURCE_DIR}/linux_mqtt_tls_subscriber_test_server.c + ${SOURCE_DIR}/linux_mqtt_tls_subscriber_test_publisher.c + ${SOURCE_DIR}/netx_mqtt_tls_subscriber_test.c) + + list(APPEND debug_secure_build_mqtt_test_cases mqtt_tls_debug_test) + set(mqtt_tls_debug_test_file_list + ${SOURCE_DIR}/netx_mqtt_tls_subscriber_test.c) +endif() + +set(test_utility_files + ${SOURCE_DIR}/netxtestcontrol.c + ${SOURCE_DIR}/nx_crypto_ciphersuites_regression.c + ${SOURCE_DIR}/nx_ram_network_driver_test_1500.c + ${SOURCE_DIR}/nx_secure_fips_test_utility.c) + +get_filename_component( + UTILITY_SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/../../../regression/interoperability_test/test_frame + ABSOLUTE) +add_library( + test_utility + ${UTILITY_SOURCE_DIR}/tls_test_get_external_test_process_output.c + ${UTILITY_SOURCE_DIR}/tls_test_launch_external_test_process.c + ${UTILITY_SOURCE_DIR}/tls_test_launch_external_test_process_in_background.c + ${UTILITY_SOURCE_DIR}/tls_test_director_clean_all.c + ${UTILITY_SOURCE_DIR}/tls_test_director_cleanup_registered_instances.c + ${UTILITY_SOURCE_DIR}/tls_test_director_create.c + ${UTILITY_SOURCE_DIR}/tls_test_director_destroy.c + ${UTILITY_SOURCE_DIR}/tls_test_director_register_test_instance.c + ${UTILITY_SOURCE_DIR}/tls_test_director_test_start.c + ${UTILITY_SOURCE_DIR}/tls_test_instance_attributes_access.c + ${UTILITY_SOURCE_DIR}/tls_test_instance_append.c + ${UTILITY_SOURCE_DIR}/tls_test_instance_create.c + ${UTILITY_SOURCE_DIR}/tls_test_instance_destroy.c + ${UTILITY_SOURCE_DIR}/tls_test_instance_find_next.c + ${UTILITY_SOURCE_DIR}/tls_test_instance_set_exit_status.c + ${UTILITY_SOURCE_DIR}/tls_test_instance_shared_buffer_manipulate.c + ${UTILITY_SOURCE_DIR}/tls_test_kill_external_test_process.c + ${UTILITY_SOURCE_DIR}/tls_test_semaphore_create.c + ${UTILITY_SOURCE_DIR}/tls_test_semaphore_destroy.c + ${UTILITY_SOURCE_DIR}/tls_test_semaphore_post.c + ${UTILITY_SOURCE_DIR}/tls_test_semaphore_wait.c + ${UTILITY_SOURCE_DIR}/tls_test_wait_all_child_process.c + ${UTILITY_SOURCE_DIR}/tls_test_wait_external_test_process.c + ${UTILITY_SOURCE_DIR}/tls_test_uninterruptable_wait.c) +target_link_libraries(test_utility PUBLIC azrtos::netxduo) +target_include_directories(test_utility PUBLIC ${UTILITY_SOURCE_DIR}) + +include(network_config.cmake) + +set(PCAP_SOURCE + ${CMAKE_CURRENT_LIST_DIR}/../../../regression/interoperability_test/nx_pcap_network_driver.c +) +foreach(test_case ${mqtt_test_cases}) + add_executable(${test_case} ${${test_case}_file_list} ${PCAP_SOURCE}) + network_config(${test_case}) + target_link_libraries(${test_case} PRIVATE test_utility pcap) + add_test( + NAME ${CMAKE_BUILD_TYPE}::${test_case} + COMMAND + bash -c + "export PATH=${SOURCE_DIR}/test_scripts/:$PATH; + ip link del ${${test_case}_interface}>/dev/null 2>&1; + ip link add ${${test_case}_interface} type veth peer name ${${test_case}_remote_interface} || exit 1; + ifconfig ${${test_case}_interface} up || { ip link del ${${test_case}_interface}; exit 1; }; + ifconfig ${${test_case}_remote_interface} ${${test_case}_remote_ip} up netmask ${TEST_NETMASK} || { ip link del ${${test_case}_interface};exit 1; }; + ethtool --offload ${${test_case}_remote_interface} tx off || { ip link del ${${test_case}_interface}; exit 1; }; + tcpdump -i ${${test_case}_remote_interface} -s 0 -w ${CMAKE_CURRENT_BINARY_DIR}/${test_case}.pcap& + pid=$! + ${CMAKE_CURRENT_BINARY_DIR}/${test_case}; + exit_code=$? + sleep 1; + kill -TERM $pid + ip link del ${${test_case}_interface} || exit 1; + [[ $exit_code = 0 ]] || [[ $exit_code = 233 ]] || { echo Exit code: $exit_code; exit $exit_code; };" + WORKING_DIRECTORY ${SOURCE_DIR}) +endforeach() diff --git a/test/cmake/mqtt_interoperability/regression/network_config.cmake b/test/cmake/mqtt_interoperability/regression/network_config.cmake new file mode 100644 index 00000000..5f75b945 --- /dev/null +++ b/test/cmake/mqtt_interoperability/regression/network_config.cmake @@ -0,0 +1,55 @@ +if(NOT ALLOCATION_PARAMETER) + execute_process(COMMAND bash "-c" "git rev-parse --verify HEAD|cut -c1-1" + OUTPUT_VARIABLE ALLOCATION_PARAMETER) + math(EXPR ALLOCATION_PARAMETER "0x${ALLOCATION_PARAMETER}") +endif() + +if(NOT TEST_SUBNET_SIZE) + set(TEST_SUBNET_SIZE 4) +endif() + +# NX_MAX_PORT is 0xffff. +math(EXPR PORT_NUMBER "65535 - (${ALLOCATION_PARAMETER} + 1) * 256") +set(INTERFACE_NUMBER ${PORT_NUMBER}) +math(EXPR TMP "256 - ${TEST_SUBNET_SIZE}") +set(TEST_NETMASK 255.255.255.${TMP}) + +set(IP_BYTE_0 10) +set(IP_BYTE_1 10) +set(IP_BYTE_2 ${ALLOCATION_PARAMETER}) +set(IP_BYTE_3 1) +set(IP_BYTE_4 2) + +macro(network_config target) + target_compile_definitions( + ${target} + PRIVATE + -DINTEROPERABILITY_TEST_ENABLE_PARALLEL_PROCESSING + -DTLS_TEST_IP_BYTE_0=${IP_BYTE_0} + -DTLS_TEST_IP_BYTE_1=${IP_BYTE_1} + -DTLS_TEST_IP_BYTE_2=${IP_BYTE_2} + -DTLS_TEST_IP_BYTE_3=${IP_BYTE_3} + -DREMOTE_IP_BYTE_0=${IP_BYTE_0} + -DREMOTE_IP_BYTE_1=${IP_BYTE_1} + -DREMOTE_IP_BYTE_2=${IP_BYTE_2} + -DREMOTE_IP_BYTE_3=${IP_BYTE_4} + -DDEVICE_SERVER_PORT=${PORT_NUMBER} + -DNX_PCAP_SOURCE_NAME=\"veth${INTERFACE_NUMBER}\") + set(${target}_interface veth${INTERFACE_NUMBER}) + set(${target}_ip ${IP_BYTE_0}.${IP_BYTE_1}.${IP_BYTE_2}.${IP_BYTE_3}) + math(EXPR INTERFACE_NUMBER "${INTERFACE_NUMBER} + 1") + set(${target}_remote_interface veth${INTERFACE_NUMBER}) + set(${target}_remote_ip ${IP_BYTE_0}.${IP_BYTE_1}.${IP_BYTE_2}.${IP_BYTE_4}) + set(${target}_port ${PORT_NUMBER}) + + # Increase numbers for next setup + math(EXPR INTERFACE_NUMBER "${INTERFACE_NUMBER} + 1") + math(EXPR IP_BYTE_3 "${IP_BYTE_3} + ${TEST_SUBNET_SIZE}") + if(${IP_BYTE_3} GREATER 253) + math(EXPR IP_BYTE_2 "${IP_BYTE_2} + 1") + set(IP_BYTE_3 1) + endif() + math(EXPR IP_BYTE_4 "${IP_BYTE_3} + 1") + math(EXPR PORT_NUMBER "${PORT_NUMBER} + 1") + +endmacro() diff --git a/test/cmake/mqtt_interoperability/run.sh b/test/cmake/mqtt_interoperability/run.sh new file mode 100755 index 00000000..dc01b08a --- /dev/null +++ b/test/cmake/mqtt_interoperability/run.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +cd $(dirname $0) + +# if threadx repo does not exist, clone it +[ -d ../threadx ] || git clone https://github.com/azure-rtos/threadx.git ../threadx --depth 1 +[ -d ../filex ] || git clone https://github.com/azure-rtos/filex.git ../filex --depth 1 +[ -f .run.sh ] || ln -sf ../threadx/scripts/cmake_bootstrap.sh .run.sh +CTEST_PARALLEL_LEVEL=1 ENABLE_IDLE=ON ./.run.sh $*
\ No newline at end of file diff --git a/test/cmake/mqtt_interoperability/test.pcap b/test/cmake/mqtt_interoperability/test.pcap Binary files differnew file mode 100644 index 00000000..58429b9e --- /dev/null +++ b/test/cmake/mqtt_interoperability/test.pcap diff --git a/test/regression/interoperability_test/mqtt_test/ca.c b/test/regression/interoperability_test/mqtt_test/ca.c new file mode 100644 index 00000000..17bb35e9 --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/ca.c @@ -0,0 +1,132 @@ +unsigned char ca_der[] = { + 0x30, 0x82, 0x05, 0xfe, 0x30, 0x82, 0x03, 0xe6, 0xa0, 0x03, 0x02, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, + 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x81, 0x8f, 0x31, 0x0b, + 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, + 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x0a, 0x43, 0x61, + 0x6c, 0x69, 0x66, 0x6f, 0x72, 0x6e, 0x69, 0x61, 0x31, 0x16, 0x30, 0x14, + 0x06, 0x03, 0x55, 0x04, 0x07, 0x0c, 0x0d, 0x53, 0x61, 0x6e, 0x20, 0x46, + 0x72, 0x61, 0x6e, 0x63, 0x69, 0x73, 0x63, 0x6f, 0x31, 0x13, 0x30, 0x11, + 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x0a, 0x42, 0x6f, 0x67, 0x75, 0x73, + 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, + 0x04, 0x0b, 0x0c, 0x0a, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x31, 0x29, 0x30, 0x27, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, + 0x20, 0x42, 0x6f, 0x67, 0x75, 0x73, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x20, + 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x20, + 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x30, 0x1e, 0x17, + 0x0d, 0x31, 0x37, 0x30, 0x33, 0x30, 0x38, 0x30, 0x34, 0x34, 0x30, 0x35, + 0x39, 0x5a, 0x17, 0x0d, 0x32, 0x37, 0x30, 0x33, 0x30, 0x38, 0x30, 0x34, + 0x34, 0x30, 0x35, 0x39, 0x5a, 0x30, 0x81, 0x8f, 0x31, 0x0b, 0x30, 0x09, + 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x13, 0x30, + 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x0a, 0x43, 0x61, 0x6c, 0x69, + 0x66, 0x6f, 0x72, 0x6e, 0x69, 0x61, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, + 0x55, 0x04, 0x07, 0x0c, 0x0d, 0x53, 0x61, 0x6e, 0x20, 0x46, 0x72, 0x61, + 0x6e, 0x63, 0x69, 0x73, 0x63, 0x6f, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, + 0x55, 0x04, 0x0a, 0x0c, 0x0a, 0x42, 0x6f, 0x67, 0x75, 0x73, 0x20, 0x49, + 0x6e, 0x63, 0x2e, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x0b, + 0x0c, 0x0a, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x31, 0x29, 0x30, 0x27, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x20, 0x42, + 0x6f, 0x67, 0x75, 0x73, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x20, 0x43, 0x65, + 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x20, 0x41, 0x75, + 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x30, 0x82, 0x02, 0x22, 0x30, + 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, + 0x05, 0x00, 0x03, 0x82, 0x02, 0x0f, 0x00, 0x30, 0x82, 0x02, 0x0a, 0x02, + 0x82, 0x02, 0x01, 0x00, 0xb6, 0x60, 0x88, 0x5b, 0xc9, 0x12, 0x1d, 0x2b, + 0x6b, 0x51, 0x62, 0x62, 0xe5, 0x94, 0x12, 0x43, 0xfa, 0x27, 0x25, 0xa4, + 0x3d, 0x91, 0x18, 0x45, 0x34, 0x43, 0xfa, 0x59, 0x65, 0x7b, 0xc3, 0xf5, + 0x74, 0x9c, 0xa6, 0xf5, 0x80, 0x91, 0xf0, 0x1d, 0x3b, 0x7d, 0xfb, 0x6b, + 0x4c, 0x44, 0xdb, 0x06, 0x8a, 0x4a, 0x7e, 0x3f, 0x1b, 0xae, 0x77, 0x61, + 0x5b, 0x66, 0x61, 0x35, 0x49, 0x77, 0xd9, 0x4f, 0x1b, 0xb9, 0xd1, 0x5d, + 0x23, 0x48, 0x8f, 0x1f, 0xf1, 0xf5, 0x63, 0x8c, 0xd1, 0xe7, 0xa5, 0xa8, + 0x9b, 0x9c, 0x62, 0xce, 0x92, 0x09, 0xd4, 0xc4, 0xdf, 0x4f, 0x72, 0x5a, + 0x43, 0xb9, 0xbc, 0xf5, 0xec, 0xe2, 0x85, 0xfa, 0x61, 0x72, 0xc1, 0x02, + 0xc5, 0x7a, 0x95, 0x6e, 0x03, 0xc5, 0x29, 0xc7, 0x96, 0x39, 0xf8, 0x4e, + 0xc4, 0x7c, 0xc7, 0x35, 0x3d, 0x9d, 0xb7, 0x53, 0x68, 0xef, 0xfa, 0x6c, + 0x18, 0xa4, 0x3f, 0x17, 0x92, 0xdc, 0x1a, 0x61, 0x01, 0x75, 0x3c, 0xa9, + 0x7e, 0x6c, 0xad, 0xbe, 0x8a, 0x62, 0x8e, 0xe8, 0xa2, 0xa9, 0xc5, 0x0a, + 0xf1, 0x0e, 0xf3, 0xff, 0xd3, 0x29, 0xc8, 0x74, 0xcd, 0x7c, 0xed, 0xe6, + 0xbe, 0x9f, 0xc9, 0x85, 0x3b, 0xe4, 0x63, 0x28, 0xd2, 0xe9, 0x38, 0xf6, + 0xdf, 0x2c, 0x19, 0x01, 0xb7, 0xa1, 0x5d, 0x85, 0x15, 0x44, 0x62, 0x0e, + 0x00, 0xc1, 0x37, 0x6d, 0xbc, 0xdc, 0xca, 0x47, 0xb4, 0x52, 0x17, 0x1b, + 0xa3, 0xcc, 0x19, 0xae, 0xd9, 0x73, 0xc7, 0x5b, 0x76, 0xe1, 0xde, 0x10, + 0x4e, 0xf9, 0x02, 0xe1, 0x68, 0x3a, 0x10, 0x51, 0x5b, 0x0e, 0x7c, 0x44, + 0x1b, 0x64, 0x25, 0xa9, 0xa1, 0x9f, 0x48, 0x2a, 0x35, 0x15, 0x0b, 0x36, + 0x83, 0xf7, 0xdf, 0x62, 0x95, 0x74, 0x31, 0xdd, 0x1b, 0xfd, 0xeb, 0x82, + 0x84, 0xcb, 0x5d, 0xf8, 0x71, 0xc3, 0x78, 0x30, 0xe9, 0xb8, 0x2f, 0xe7, + 0x59, 0xd2, 0xeb, 0x98, 0x03, 0xd0, 0x17, 0x03, 0x88, 0xc4, 0x6b, 0x6c, + 0x14, 0x5c, 0x95, 0x18, 0xc0, 0xbf, 0x42, 0x95, 0xfe, 0x23, 0xb3, 0x0b, + 0x6c, 0x46, 0x59, 0xc8, 0x11, 0x27, 0xc6, 0x5a, 0x09, 0x45, 0x09, 0x3f, + 0x23, 0xf0, 0xd9, 0x5d, 0x49, 0x40, 0x95, 0xda, 0x9f, 0x89, 0xca, 0x84, + 0x7a, 0xf2, 0x49, 0x0d, 0x43, 0xa2, 0x8b, 0x68, 0x16, 0x2d, 0xdc, 0xff, + 0xd5, 0x82, 0xfc, 0x3f, 0x6f, 0xb7, 0x98, 0x34, 0xdb, 0xbe, 0x0b, 0xea, + 0x2a, 0x64, 0xfa, 0x99, 0x0c, 0x39, 0x05, 0xe6, 0x8b, 0x9b, 0xd1, 0x6e, + 0x1c, 0x9a, 0x19, 0x0f, 0xde, 0xba, 0xae, 0x33, 0xbe, 0x88, 0x8e, 0x1a, + 0x51, 0x9f, 0x26, 0xbb, 0x87, 0xad, 0x76, 0x54, 0x7a, 0xae, 0xd3, 0x62, + 0xa4, 0x9d, 0x94, 0x10, 0xc4, 0x0b, 0x64, 0x19, 0xfd, 0xb9, 0x2b, 0xd6, + 0x19, 0x87, 0x62, 0xac, 0x43, 0x9b, 0xb0, 0x56, 0x27, 0x90, 0xa0, 0xb5, + 0xef, 0xc3, 0x05, 0x20, 0x1e, 0xa4, 0xe5, 0x46, 0xf5, 0x28, 0x5c, 0x02, + 0xaf, 0xcb, 0x31, 0x2f, 0xba, 0xa5, 0x4b, 0x4b, 0x1d, 0xc9, 0x25, 0xfe, + 0xd4, 0x15, 0x8a, 0xa0, 0xde, 0xe3, 0x0b, 0x97, 0x57, 0x2c, 0xc2, 0xf1, + 0x9c, 0xad, 0x49, 0xb5, 0xa3, 0x19, 0xb9, 0xcb, 0x84, 0xdf, 0xd9, 0x24, + 0xe4, 0x03, 0x1d, 0xa7, 0xca, 0x58, 0xaf, 0x35, 0x28, 0x92, 0x3c, 0x1d, + 0x44, 0x10, 0x91, 0xfc, 0x41, 0x1e, 0x67, 0x43, 0x37, 0xa6, 0x8b, 0xd2, + 0x47, 0x27, 0x57, 0xa9, 0x51, 0x32, 0x59, 0xce, 0xb3, 0xf4, 0x5b, 0x87, + 0xa1, 0xdb, 0x1b, 0x11, 0x78, 0xf4, 0x75, 0xf9, 0x3f, 0xa2, 0x26, 0x7f, + 0x46, 0x45, 0x9c, 0x68, 0xf2, 0xa4, 0xdf, 0xc1, 0x94, 0x71, 0x23, 0xa1, + 0x15, 0x9a, 0xad, 0x6e, 0xe4, 0x3a, 0x24, 0xe4, 0x1b, 0xee, 0x50, 0x87, + 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x63, 0x30, 0x61, 0x30, 0x0e, 0x06, + 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x01, + 0x06, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, + 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, + 0x0e, 0x04, 0x16, 0x04, 0x14, 0xf6, 0x6a, 0x39, 0x1f, 0xaa, 0x47, 0xa3, + 0x54, 0x5e, 0x0f, 0x06, 0xa1, 0xe4, 0xec, 0x85, 0x40, 0xb0, 0x6c, 0x45, + 0x46, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, + 0x80, 0x14, 0xf6, 0x6a, 0x39, 0x1f, 0xaa, 0x47, 0xa3, 0x54, 0x5e, 0x0f, + 0x06, 0xa1, 0xe4, 0xec, 0x85, 0x40, 0xb0, 0x6c, 0x45, 0x46, 0x30, 0x0d, + 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, + 0x00, 0x03, 0x82, 0x02, 0x01, 0x00, 0xa2, 0x1a, 0x64, 0x34, 0x1b, 0x37, + 0xb3, 0x42, 0x3a, 0x0a, 0x05, 0xd0, 0x59, 0x2d, 0x17, 0xad, 0xc7, 0xfc, + 0x0c, 0x32, 0xc2, 0x1f, 0x00, 0xa6, 0xf8, 0x88, 0xc0, 0xe5, 0x49, 0x5d, + 0x3e, 0x0b, 0xbf, 0xec, 0x32, 0xeb, 0x9c, 0xf9, 0x18, 0x39, 0x3a, 0x98, + 0x00, 0xb8, 0x76, 0x43, 0xa6, 0x60, 0x3b, 0xb8, 0x35, 0xf4, 0x2a, 0x30, + 0xf7, 0x6c, 0x74, 0x79, 0x18, 0x27, 0x73, 0x5b, 0xa0, 0xf6, 0xb7, 0x30, + 0x15, 0xa5, 0x11, 0x0f, 0xa1, 0xcd, 0xad, 0xeb, 0x18, 0xd6, 0x8c, 0x1a, + 0xb1, 0x24, 0x66, 0x03, 0x54, 0xfb, 0x9a, 0x21, 0xf4, 0xe1, 0x94, 0x5f, + 0xe4, 0x6f, 0x48, 0xe7, 0x40, 0x64, 0xad, 0xd4, 0x0a, 0xa1, 0xe0, 0xf9, + 0xa0, 0x6b, 0xa5, 0xa3, 0x52, 0x70, 0xbd, 0x7e, 0xd1, 0x4b, 0x62, 0xc4, + 0x5b, 0x7e, 0xde, 0x23, 0xc2, 0x04, 0xb9, 0x38, 0x4d, 0x69, 0xdc, 0xf5, + 0xe2, 0x43, 0x92, 0x5d, 0x55, 0x2f, 0xae, 0x4c, 0x18, 0xe6, 0x5c, 0xf5, + 0x01, 0x49, 0xc1, 0x30, 0xa5, 0xe4, 0x4f, 0x99, 0xbc, 0xc1, 0xf5, 0xe0, + 0x27, 0xa5, 0x8b, 0xd8, 0x03, 0xb5, 0x1c, 0x3f, 0x29, 0x21, 0x38, 0x77, + 0x16, 0x87, 0x89, 0xf3, 0xc8, 0x2f, 0x81, 0x9e, 0xbc, 0x2d, 0xeb, 0xdc, + 0xa3, 0x56, 0xe6, 0x83, 0xaf, 0x3f, 0xeb, 0x31, 0xcd, 0x33, 0x69, 0x7f, + 0x77, 0x13, 0x10, 0x1a, 0x74, 0xa5, 0x1d, 0xe6, 0x57, 0xe5, 0x0e, 0xb6, + 0x38, 0x23, 0xb0, 0x15, 0xc7, 0x12, 0xf1, 0x94, 0x5d, 0x7a, 0x01, 0x53, + 0x10, 0x2a, 0x0b, 0x38, 0x28, 0x96, 0xc6, 0x5f, 0xdc, 0x53, 0x9d, 0x79, + 0xdc, 0x54, 0xb6, 0x2d, 0x88, 0x6d, 0x72, 0x1d, 0x33, 0x18, 0xb2, 0x45, + 0xf5, 0x7c, 0xcf, 0x9d, 0xe8, 0xe3, 0x23, 0xc9, 0x34, 0x06, 0xd4, 0x19, + 0x8e, 0x3c, 0x45, 0xf2, 0x76, 0x32, 0x69, 0x8d, 0xfe, 0xb2, 0x7a, 0x16, + 0x72, 0x97, 0x84, 0x46, 0x88, 0x7f, 0x7c, 0xdb, 0xa2, 0x21, 0x31, 0xf6, + 0x3d, 0xe2, 0xbe, 0xc9, 0x07, 0x01, 0x8d, 0x1d, 0x88, 0x05, 0xf0, 0x6d, + 0xca, 0xcb, 0x97, 0xbf, 0x11, 0xeb, 0x32, 0xe2, 0x86, 0x40, 0xcb, 0xb3, + 0xb5, 0xa4, 0xc5, 0xa0, 0x06, 0xc2, 0x5b, 0xb2, 0x3a, 0xf5, 0x64, 0x12, + 0xe8, 0x5e, 0xd7, 0x87, 0x1c, 0x46, 0xff, 0x98, 0x0b, 0xb5, 0x51, 0x89, + 0xdd, 0xeb, 0x90, 0x8a, 0xad, 0xb6, 0x3e, 0x78, 0xd7, 0x95, 0x16, 0x5f, + 0x58, 0x12, 0x48, 0x1e, 0x64, 0x25, 0x3c, 0xeb, 0x46, 0xe7, 0xbf, 0xbe, + 0xf7, 0x47, 0xcd, 0x52, 0x24, 0x05, 0x83, 0x44, 0x93, 0xe4, 0x63, 0x94, + 0xf6, 0x70, 0x52, 0x7c, 0x2f, 0x03, 0x60, 0xe5, 0xc2, 0xc8, 0xf4, 0x5b, + 0x39, 0xd5, 0x57, 0x58, 0x20, 0x05, 0x30, 0xd8, 0x8a, 0x8c, 0x54, 0x6d, + 0x39, 0x95, 0xcf, 0x8a, 0x45, 0xf0, 0xc7, 0xc6, 0xc5, 0xfc, 0xd4, 0xd3, + 0xbc, 0x3f, 0xa6, 0x65, 0xab, 0xc0, 0x57, 0xe9, 0xa0, 0xf9, 0x7a, 0x41, + 0x0a, 0x82, 0x48, 0x37, 0x2b, 0x7f, 0x28, 0x96, 0x76, 0xcc, 0xb7, 0xd3, + 0xac, 0x26, 0xd4, 0x6c, 0x68, 0x3b, 0xcb, 0x7b, 0x96, 0x32, 0xc7, 0xfd, + 0x5c, 0x46, 0x1f, 0x9c, 0xff, 0x6b, 0xf3, 0x25, 0x53, 0xc6, 0xa5, 0x53, + 0xdb, 0x4e, 0x16, 0x03, 0x14, 0x31, 0x0e, 0xd6, 0xda, 0xb5, 0x56, 0x2f, + 0x4b, 0x15, 0x00, 0xe9, 0x57, 0x2b, 0x3a, 0xa5, 0xa6, 0x5c, 0x4d, 0xf9, + 0x0c, 0x39, 0x4f, 0x19, 0x51, 0xd8, 0x2a, 0x0b, 0x58, 0x12, 0xd9, 0x37, + 0x2b, 0x8c, 0xd2, 0x22, 0xe6, 0xf2, 0xcb, 0xbf, 0x2f, 0xae, 0x7c, 0xe5, + 0xe2, 0xb5, 0x69, 0x65, 0x4f, 0x60, 0xe8, 0x31, 0x3a, 0xb6, 0xef, 0xa8, + 0x5d, 0x56, 0xe6, 0xfa, 0xab, 0x26, 0x82, 0x2d, 0xac, 0x69, 0xbd, 0x6d, + 0x63, 0x21 +}; +unsigned int ca_der_len = 1538; diff --git a/test/regression/interoperability_test/mqtt_test/generic_test_entry_0.c b/test/regression/interoperability_test/mqtt_test/generic_test_entry_0.c new file mode 100644 index 00000000..d06cdf08 --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/generic_test_entry_0.c @@ -0,0 +1,96 @@ +#include "tls_test_frame.h" + +/* Declare the test entries of test instances. */ +INT mqtt_server_entry(TLS_TEST_INSTANCE* instance_ptr); +INT mqtt_publisher_entry(TLS_TEST_INSTANCE* instance_ptr); +INT mqtt_subscriber_entry(TLS_TEST_INSTANCE* instance_ptr); + +/* Declare semaphores. */ +TLS_TEST_SEMAPHORE* semaphore_mqtt_server_prepared; +TLS_TEST_SEMAPHORE* semaphore_mqtt_topic_subscribed; +TLS_TEST_SEMAPHORE* semaphore_mqtt_message_published; +TLS_TEST_SEMAPHORE* semaphore_mqtt_test_finished; + +INT main(INT argc, CHAR* argv[]) +{ +INT status; +TLS_TEST_INSTANCE *ins0, *ins1, *ins2; +TLS_TEST_DIRECTOR *director; +INT exit_status[3]; + + /* Create three test instances. */ + status = tls_test_instance_create(&ins0, /* test instance ptr */ + "mqtt_server", /* instance name */ + mqtt_server_entry, /* test entry */ + 0, /* delay(seconds) */ + 20, /* timeout(seconds) */ + 1024, /* shared buffer size */ + NULL); /* reserved */ + return_value_if_fail(TLS_TEST_SUCCESS == status, status); + + status = tls_test_instance_create(&ins1, + "mqtt_subscriber", + mqtt_subscriber_entry, + 0, + 20, + 1024, + NULL); + return_value_if_fail(TLS_TEST_SUCCESS == status, status); + + status = tls_test_instance_create(&ins2, + "mqtt_publisher", + mqtt_publisher_entry, + 0, + 20, + 1024, + NULL); + return_value_if_fail(TLS_TEST_SUCCESS == status, status); + + /* Create test semaphores whose value will be initialized as zero. */ + status = tls_test_semaphore_create(&semaphore_mqtt_server_prepared, 0); + return_value_if_fail(TLS_TEST_SUCCESS == status, status); + status = tls_test_semaphore_create(&semaphore_mqtt_message_published, 0); + return_value_if_fail(TLS_TEST_SUCCESS == status, status); + status = tls_test_semaphore_create(&semaphore_mqtt_topic_subscribed, 0); + return_value_if_fail(TLS_TEST_SUCCESS == status, status); + status = tls_test_semaphore_create(&semaphore_mqtt_test_finished, 0); + return_value_if_fail(TLS_TEST_SUCCESS == status, status); + + /* Create the test director. */ + status = tls_test_director_create(&director, NULL /* reserved */); + return_value_if_fail(TLS_TEST_SUCCESS == status, status); + + /* Register test instances to the director. */ + status = tls_test_director_register_test_instance(director, ins0); + status += tls_test_director_register_test_instance(director, ins1); + status += tls_test_director_register_test_instance(director, ins2); + return_value_if_fail(TLS_TEST_SUCCESS == status, status); + + /* Launch test. */ + status = tls_test_director_test_start(director); + return_value_if_fail(TLS_TEST_SUCCESS == status, status); + + /* Show test results. */ + tls_test_instance_show_exit_status(ins0); + tls_test_instance_show_exit_status(ins1); + tls_test_instance_show_exit_status(ins2); + + /* Collect exit code. */ + tls_test_instance_get_exit_status(ins0, &(exit_status[0])); + tls_test_instance_get_exit_status(ins1, &(exit_status[1])); + tls_test_instance_get_exit_status(ins1, &(exit_status[2])); + + /* Destroy all created instances. */ + tls_test_director_clean_all(director); + + /* Destroy the semaphore. */ + tls_test_semaphore_destroy(semaphore_mqtt_server_prepared); + tls_test_semaphore_destroy(semaphore_mqtt_topic_subscribed); + tls_test_semaphore_destroy(semaphore_mqtt_message_published); + tls_test_semaphore_destroy(semaphore_mqtt_test_finished); + + /* Check the exit codes of two instances. */ + return_value_if_fail((TLS_TEST_NOT_AVAILABLE != exit_status[0]) && (TLS_TEST_NOT_AVAILABLE != exit_status[1]) && (TLS_TEST_NOT_AVAILABLE != exit_status[2]), TLS_TEST_NOT_AVAILABLE); + return_value_if_fail((0 == exit_status[0]) && (0 == exit_status[1]) && (0 == exit_status[2]), TLS_TEST_UNKNOWN_TYPE_ERROR); + return TLS_TEST_SUCCESS; +} diff --git a/test/regression/interoperability_test/mqtt_test/linux_mqtt_subscriber_empty_message_test_publisher.c b/test/regression/interoperability_test/mqtt_test/linux_mqtt_subscriber_empty_message_test_publisher.c new file mode 100644 index 00000000..e4392470 --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/linux_mqtt_subscriber_empty_message_test_publisher.c @@ -0,0 +1,36 @@ +#include "mqtt_interoperability_test.h" + +/* Global semaphore address. */ +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_topic_subscribed; +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_message_published; + +INT mqtt_publisher_entry(TLS_TEST_INSTANCE* instance_ptr) +{ +CHAR* name; +/* Publish a messge to the test topic. */ +CHAR* external_cmd[] = { "no_tls_pub.sh","-p", STRING(MQTT_PORT), "-t", "test", "-n", NULL}; +INT status, exit_status; + + /* Get the name of the test instance. */ + status = tls_test_instance_get_name(instance_ptr, &name); + return_value_if_fail(TLS_TEST_SUCCESS == status, status); + + /* Wait for the subscriber. */ + tls_test_semaphore_wait(semaphore_mqtt_topic_subscribed); + + /* Wait for subscriber for one seconds. */ + tls_test_sleep(1); + print_error_message("Instance %s: get semaphore_mqtt_topic_subscribed.\n", name); + + /* Call an external script in the directory prepared_test_program. */ + status = tls_test_launch_external_test_process(&exit_status, external_cmd); + return_value_if_fail(TLS_TEST_SUCCESS == status, status); + + /* Post the semaphore to indicate that one message is published. */ + tls_test_sleep(1); + tls_test_semaphore_post(semaphore_mqtt_message_published); + + /* Check for exit status of the external script. */ + return_value_if_fail(0 == exit_status, TLS_TEST_INSTANCE_FAILED); + return 0; +}; diff --git a/test/regression/interoperability_test/mqtt_test/linux_mqtt_subscriber_test_entry.c b/test/regression/interoperability_test/mqtt_test/linux_mqtt_subscriber_test_entry.c new file mode 100644 index 00000000..03e6b657 --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/linux_mqtt_subscriber_test_entry.c @@ -0,0 +1 @@ +#include "generic_test_entry_0.c" diff --git a/test/regression/interoperability_test/mqtt_test/linux_mqtt_subscriber_test_publisher.c b/test/regression/interoperability_test/mqtt_test/linux_mqtt_subscriber_test_publisher.c new file mode 100644 index 00000000..f4f30ee9 --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/linux_mqtt_subscriber_test_publisher.c @@ -0,0 +1,36 @@ +#include "mqtt_interoperability_test.h" + +/* Global semaphore address. */ +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_topic_subscribed; +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_message_published; + +INT mqtt_publisher_entry(TLS_TEST_INSTANCE* instance_ptr) +{ +CHAR* name; +/* Publish a messge to the test topic. */ +CHAR* external_cmd[] = { "no_tls_pub.sh","-p", STRING(MQTT_PORT), "-t", "test", "-m", "hello", NULL}; +INT status, exit_status; + + /* Get the name of the test instance. */ + status = tls_test_instance_get_name(instance_ptr, &name); + return_value_if_fail(TLS_TEST_SUCCESS == status, status); + + /* Wait for the subscriber. */ + tls_test_semaphore_wait(semaphore_mqtt_topic_subscribed); + + /* Wait for subscriber for one seconds. */ + tls_test_sleep(1); + print_error_message("Instance %s: get semaphore_mqtt_topic_subscribed.\n", name); + + /* Call an external script in the directory prepared_test_program. */ + status = tls_test_launch_external_test_process(&exit_status, external_cmd); + return_value_if_fail(TLS_TEST_SUCCESS == status, status); + + /* Post the semaphore to indicate that one message is published. */ + tls_test_sleep(1); + tls_test_semaphore_post(semaphore_mqtt_message_published); + + /* Check for exit status of the external script. */ + return_value_if_fail(0 == exit_status, TLS_TEST_INSTANCE_FAILED); + return 0; +}; diff --git a/test/regression/interoperability_test/mqtt_test/linux_mqtt_subscriber_test_server.c b/test/regression/interoperability_test/mqtt_test/linux_mqtt_subscriber_test_server.c new file mode 100644 index 00000000..abb539e8 --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/linux_mqtt_subscriber_test_server.c @@ -0,0 +1,47 @@ +#include "mqtt_interoperability_test.h" + +#ifdef NXD_MQTT_REQUIRE_TLS +INT mqtt_server_entry(TLS_TEST_INSTANCE* instance_ptr) +{ + return TLS_TEST_NOT_AVAILABLE; +} +#else +/* Global semaphore address. */ +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_server_prepared; +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_test_finished; + +INT mqtt_server_entry(TLS_TEST_INSTANCE* instance_ptr) +{ +CHAR* name; +CHAR* external_cmd[] = { "no_tls_server.sh", "-p", STRING(MQTT_PORT), NULL}; +INT status, exit_status; +TLS_TEST_EXTERNAL_TEST_PROCESS external_test_process; + + /* Get the name of the test instance. */ + status = tls_test_instance_get_name(instance_ptr, &name); + return_value_if_fail(TLS_TEST_SUCCESS == status, status); + + /* Launch the mqtt server in background. */ + status = tls_test_launch_external_test_process_in_background(&external_test_process, external_cmd); + return_value_if_fail(TLS_TEST_SUCCESS == status, status); + + /* Post the semaphore to indicate that mqtt server is prepared. */ + tls_test_sleep(2); + print_error_message("Instance %s: post semaphore_mqtt_server_prepared.\n", name); + tls_test_semaphore_post(semaphore_mqtt_server_prepared); + + /* Wait for the termination of the test. */ + print_error_message("Instance %s: wait for semaphore_mqtt_test_finished.\n", name); + tls_test_semaphore_wait(semaphore_mqtt_test_finished); + + /* Kill the mqtt server by SIGTERM. */ + status = tls_test_kill_external_test_process(&external_test_process); + status += tls_test_wait_external_test_process(&external_test_process, &exit_status); + return_value_if_fail(TLS_TEST_SUCCESS == status, TLS_TEST_UNKNOWN_TYPE_ERROR); + + /* Make sure that the mqtt server is killed by SIGTERM. */ + /* For a shell process killed by signal, the return value must be (128 + signal number). */ + return_value_if_fail(128 + SIGTERM == exit_status, TLS_TEST_INSTANCE_FAILED); + return 0; +} +#endif diff --git a/test/regression/interoperability_test/mqtt_test/linux_mqtt_tls_subscriber_test_entry.c b/test/regression/interoperability_test/mqtt_test/linux_mqtt_tls_subscriber_test_entry.c new file mode 100644 index 00000000..03e6b657 --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/linux_mqtt_tls_subscriber_test_entry.c @@ -0,0 +1 @@ +#include "generic_test_entry_0.c" diff --git a/test/regression/interoperability_test/mqtt_test/linux_mqtt_tls_subscriber_test_publisher.c b/test/regression/interoperability_test/mqtt_test/linux_mqtt_tls_subscriber_test_publisher.c new file mode 100644 index 00000000..4c112f2d --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/linux_mqtt_tls_subscriber_test_publisher.c @@ -0,0 +1,43 @@ +#include "mqtt_interoperability_test.h" + +#ifndef NX_SECURE_ENABLE +INT mqtt_publisher_entry(TLS_TEST_INSTANCE* instance_ptr) +{ + return 0; +} +#else +/* Global semaphore address. */ +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_topic_subscribed; +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_message_published; + +INT mqtt_publisher_entry(TLS_TEST_INSTANCE* instance_ptr) +{ +CHAR* name; +/* Publish a messge to the test topic. */ +CHAR* external_cmd[] = { "pub.sh","-p", STRING(MQTT_PORT), "-t", "test", "-m", "hello", NULL}; +INT status, exit_status; + + /* Get the name of the test instance. */ + status = tls_test_instance_get_name(instance_ptr, &name); + return_value_if_fail(TLS_TEST_SUCCESS == status, status); + + /* Wait for the subscriber. */ + tls_test_semaphore_wait(semaphore_mqtt_topic_subscribed); + + /* Wait for subscriber for one seconds. */ + tls_test_sleep(1); + print_error_message("Instance %s: get semaphore_mqtt_topic_subscribed.\n", name); + + /* Call an external script in the directory prepared_test_program. */ + status = tls_test_launch_external_test_process(&exit_status, external_cmd); + return_value_if_fail(TLS_TEST_SUCCESS == status, status); + + /* Post the semaphore to indicate that one message is published. */ + tls_test_sleep(1); + tls_test_semaphore_post(semaphore_mqtt_message_published); + + /* Check for exit status of the external script. */ + return_value_if_fail(0 == exit_status, TLS_TEST_INSTANCE_FAILED); + return 0; +}; +#endif diff --git a/test/regression/interoperability_test/mqtt_test/linux_mqtt_tls_subscriber_test_server.c b/test/regression/interoperability_test/mqtt_test/linux_mqtt_tls_subscriber_test_server.c new file mode 100644 index 00000000..274e462a --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/linux_mqtt_tls_subscriber_test_server.c @@ -0,0 +1,47 @@ +#include "mqtt_interoperability_test.h" + +#ifndef NX_SECURE_ENABLE +INT mqtt_server_entry(TLS_TEST_INSTANCE* instance_ptr) +{ + return TLS_TEST_NOT_AVAILABLE; +} +#else +/* Global semaphore address. */ +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_server_prepared; +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_test_finished; + +INT mqtt_server_entry(TLS_TEST_INSTANCE* instance_ptr) +{ +CHAR* name; +CHAR* external_cmd[] = { "certificate_server.sh", "-p", STRING(MQTT_PORT), NULL}; +INT status, exit_status; +TLS_TEST_EXTERNAL_TEST_PROCESS external_test_process; + + /* Get the name of the test instance. */ + status = tls_test_instance_get_name(instance_ptr, &name); + return_value_if_fail(TLS_TEST_SUCCESS == status, status); + + /* Launch the mqtt server in background. */ + status = tls_test_launch_external_test_process_in_background(&external_test_process, external_cmd); + return_value_if_fail(TLS_TEST_SUCCESS == status, status); + + /* Post the semaphore to indicate that mqtt server is prepared. */ + tls_test_sleep(1); + print_error_message("Instance %s: post semaphore_mqtt_server_prepared.\n", name); + tls_test_semaphore_post(semaphore_mqtt_server_prepared); + + /* Wait for the termination of the test. */ + print_error_message("Instance %s: wait for semaphore_mqtt_test_finished.\n", name); + tls_test_semaphore_wait(semaphore_mqtt_test_finished); + + /* Kill the mqtt server by SIGTERM. */ + status = tls_test_kill_external_test_process(&external_test_process); + status += tls_test_wait_external_test_process(&external_test_process, &exit_status); + return_value_if_fail(TLS_TEST_SUCCESS == status, TLS_TEST_UNKNOWN_TYPE_ERROR); + + /* Make sure that the mqtt server is killed by SIGTERM. */ + /* For a shell process killed by signal, the return value must be (128 + signal number). */ + return_value_if_fail(128 + SIGTERM == exit_status, TLS_TEST_INSTANCE_FAILED); + return 0; +} +#endif diff --git a/test/regression/interoperability_test/mqtt_test/linux_mqtt_tls_subscriber_twice_test_publisher.c b/test/regression/interoperability_test/mqtt_test/linux_mqtt_tls_subscriber_twice_test_publisher.c new file mode 100644 index 00000000..17e6913e --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/linux_mqtt_tls_subscriber_twice_test_publisher.c @@ -0,0 +1,48 @@ +#include "mqtt_interoperability_test.h" + +#ifndef NX_SECURE_ENABLE +INT mqtt_publisher_entry(TLS_TEST_INSTANCE* instance_ptr) +{ + return 0; +} +#else +/* Global semaphore address. */ +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_topic_subscribed; +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_message_published; + +INT mqtt_publisher_entry(TLS_TEST_INSTANCE* instance_ptr) +{ +CHAR* name; +/* Publish a messge to the test topic. */ +CHAR* external_cmd[] = { "pub.sh","-p", STRING(MQTT_PORT), "-t", "test", "-m", "hello", NULL}; +INT status, exit_status; +UINT i; + + /* Get the name of the test instance. */ + status = tls_test_instance_get_name(instance_ptr, &name); + return_value_if_fail(TLS_TEST_SUCCESS == status, status); + + for (i = 0; i < 3; i++) + { + + /* Wait for the subscriber. */ + tls_test_semaphore_wait(semaphore_mqtt_topic_subscribed); + + /* Wait for subscriber for one seconds. */ + tls_test_sleep(1); + print_error_message("Instance %s: get semaphore_mqtt_topic_subscribed.\n", name); + + /* Call an external script in the directory prepared_test_program. */ + status = tls_test_launch_external_test_process(&exit_status, external_cmd); + return_value_if_fail(TLS_TEST_SUCCESS == status, status); + + /* Post the semaphore to indicate that one message is published. */ + tls_test_sleep(1); + tls_test_semaphore_post(semaphore_mqtt_message_published); + } + + /* Check for exit status of the external script. */ + return_value_if_fail(0 == exit_status, TLS_TEST_INSTANCE_FAILED); + return 0; +}; +#endif diff --git a/test/regression/interoperability_test/mqtt_test/mqtt_interoperability_test.h b/test/regression/interoperability_test/mqtt_test/mqtt_interoperability_test.h new file mode 100644 index 00000000..55ca6e49 --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/mqtt_interoperability_test.h @@ -0,0 +1,15 @@ +#ifndef __MQTT_INTEROPERABILITY_TEST__ +#define __MQTT_INTEROPERABILITY_TEST__ + +#include "tls_test_frame.h" + +#define MQTT_PORT 8884 + +#ifndef MQTT_PORT +#define MQTT_PORT 8883 +#endif /* MQTT_PORT */ + +#define STRING(s) str(s) +#define str(s) #s + +#endif /* __MQTT_INEROPERABILITY_TEST__ */ diff --git a/test/regression/interoperability_test/mqtt_test/netx_mqtt_double_subscribers_test.c b/test/regression/interoperability_test/mqtt_test/netx_mqtt_double_subscribers_test.c new file mode 100644 index 00000000..e976963f --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/netx_mqtt_double_subscribers_test.c @@ -0,0 +1,329 @@ +#include "mqtt_interoperability_test.h" +#include "ca.c" + +#ifndef NX_SECURE_ENABLE +INT mqtt_subscriber_entry(TLS_TEST_INSTANCE* instance_ptr) +{ + print_error_message( "NX_SEUCRE_ENABLE is not defined.\n"); + return 0; +} +#else /* ifdef NX_SECURE_ENABLE */ + +#include "nxd_mqtt_client.h" + +/* Define the ThreadX and NetX object control blocks... */ + +NX_PACKET_POOL pool_0; +NX_IP ip_0; + +NX_TCP_SOCKET tcp_socket; + +#define REMOTE_SERVER_PORT 4433 +#define LOCAL_CLIENT_PORT 30024 + +/* Define the IP thread's stack area. */ +ULONG ip_thread_stack[3 * 1024 / sizeof(ULONG)]; + +/* Define packet pool for the demonstration. */ +#define NX_PACKET_POOL_SIZE ((1536 + sizeof(NX_PACKET)) * 64) +ULONG packet_pool_area[NX_PACKET_POOL_SIZE/sizeof(ULONG) + 64 / sizeof(ULONG)]; + +/* Define the ARP cache area. */ +ULONG arp_space_area[512 / sizeof(ULONG)]; + +/* Define the demo thread. */ +ULONG demo_thread_stack[6 * 1024 / sizeof(ULONG)]; +TX_THREAD demo_thread; + +/* Define the pcap driver function. */ +VOID _nx_pcap_network_driver(NX_IP_DRIVER *driver_req_ptr); + +/* Define a global variable for the pointer of current test instance. */ +TLS_TEST_INSTANCE* client_instance_ptr; +void client_thread_entry(ULONG thread_input); + +#ifdef DEBUG_NX_SECURE +INT main() +{ + tx_kernel_enter(); +} +#else +/* Declare semaphores. */ +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_server_prepared; +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_topic_subscribed; +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_message_published; +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_test_finished; + +INT mqtt_subscriber_entry(TLS_TEST_INSTANCE* instance_ptr) +{ + client_instance_ptr = instance_ptr; + tx_kernel_enter(); +} +#endif + +#ifdef CTEST +VOID test_application_define(void *first_unused_memory) +#else +void tx_application_define(void *first_unused_memory) +#endif +{ +UINT status; + + /* Initialize the NetX system. */ + nx_system_initialize(); + + /* Create a packet pool. */ + status = nx_packet_pool_create(&pool_0, "NetX Main Packet Pool", 1536, (ULONG*)(((int)packet_pool_area + 64) & ~63) , NX_PACKET_POOL_SIZE); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Create an IP instance. */ + status = nx_ip_create(&ip_0, + "NetX IP Instance 0", + TLS_TEST_IP_ADDRESS_NUMBER, + 0xFFFFFF00UL, + &pool_0, + _nx_pcap_network_driver, + (UCHAR*)ip_thread_stack, + sizeof(ip_thread_stack), + 1); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Enable ARP and supply ARP cache memory for IP Instance 0. */ + status = nx_arp_enable(&ip_0, (void *)arp_space_area, sizeof(arp_space_area)); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Enable TCP traffic. */ + status = nx_tcp_enable(&ip_0); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Enable UDP traffic. */ + status = nx_udp_enable(&ip_0); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Enable ICMP. */ + status = nx_icmp_enable(&ip_0); + show_error_message_if_fail(NX_SUCCESS == status); + + status = nx_ip_fragment_enable(&ip_0); + show_error_message_if_fail(NX_SUCCESS == status); + tx_thread_create(&demo_thread, "demo thread", client_thread_entry, 0, + demo_thread_stack, sizeof(demo_thread_stack), + 16, 16, 4, TX_AUTO_START); +} + +/* Declare the MQTT client control block. */ +static NXD_MQTT_CLIENT mqtt_client; +static NXD_MQTT_CLIENT mqtt_client_0; +#define CLIENT_ID_STRING "mytestclient" +#define CLIENT_0_ID_STRING "mysecondtestclient" +#define MQTT_CLIENT_STACK_SIZE 4096 + +/* Define the priority of the MQTT internal thread. */ +#define MQTT_THREAD_PRIORTY 2 + +/* Declare a 2000-byte memory space the application supplies to the MQTT client instance. */ +static ULONG client_memory[2000 / sizeof(ULONG)]; +static ULONG client_0_memory[2000 / sizeof(ULONG)]; + +/* Declare the MQTT thread stack space. */ +static ULONG mqtt_client_stack[MQTT_CLIENT_STACK_SIZE / sizeof(ULONG)]; +static ULONG mqtt_client_0_stack[MQTT_CLIENT_STACK_SIZE / sizeof(ULONG)]; + +/* Define the MQTT keep alive timer for 5 minutes */ +#define MQTT_KEEP_ALIVE_TIMER 300 + +/* Define the subscribed topic. */ +#define TOPIC_NAME "test" + +#define QOS0 0 +#define QOS1 1 + +/* Declare external cryptosuites. */ +extern const NX_SECURE_TLS_CRYPTO nx_crypto_tls_ciphers; + +/* Define crypto metadata buffer. */ +static UCHAR metadata_buffer[5*4096]; +static UCHAR metadata_buffer_0[5*4096]; + +/* Declare buffers to hold message and topic. */ +static UCHAR message_buffer[NXD_MQTT_MAX_MESSAGE_LENGTH]; +static UCHAR topic_buffer[NXD_MQTT_MAX_TOPIC_NAME_LENGTH]; + +/* For remote certificate. */ +NX_SECURE_X509_CERT remote_certificate, remote_issuer; +NX_SECURE_X509_CERT remote_certificate_0, remote_issuer_0, ca_certificate; +UCHAR remote_cert_buffer[2000]; +UCHAR remote_issuer_buffer[2000]; +UCHAR remote_cert_buffer_0[2000]; +UCHAR remote_issuer_buffer_0[2000]; + +/* Define the callback function for tls connection. */ +UINT tls_setup_method(NXD_MQTT_CLIENT* client_ptr, NX_SECURE_TLS_SESSION* tls_session, + NX_SECURE_X509_CERT* certificate, NX_SECURE_X509_CERT* trusted_certificate) +{ + nx_secure_tls_remote_certificate_allocate(tls_session, &remote_certificate, remote_cert_buffer, sizeof(remote_cert_buffer)); + nx_secure_tls_remote_certificate_allocate(tls_session, &remote_issuer, remote_issuer_buffer, sizeof(remote_issuer_buffer)); + + nx_secure_x509_certificate_initialize(&ca_certificate, ca_der, ca_der_len, + NX_NULL, 0, NX_NULL, 0, NX_SECURE_X509_KEY_TYPE_NONE); + nx_secure_tls_trusted_certificate_add(tls_session, &ca_certificate); + + return(NX_SUCCESS); +} + +UINT tls_setup_method_0(NXD_MQTT_CLIENT* client_ptr, NX_SECURE_TLS_SESSION* tls_session, + NX_SECURE_X509_CERT* certificate, NX_SECURE_X509_CERT* trusted_certificate) +{ + nx_secure_tls_remote_certificate_allocate(tls_session, &remote_certificate_0, remote_cert_buffer_0, sizeof(remote_cert_buffer_0)); + nx_secure_tls_remote_certificate_allocate(tls_session, &remote_issuer_0, remote_issuer_buffer_0, sizeof(remote_issuer_buffer_0)); + + nx_secure_x509_certificate_initialize(&ca_certificate, ca_der, ca_der_len, + NX_NULL, 0, NX_NULL, 0, NX_SECURE_X509_KEY_TYPE_NONE); + nx_secure_tls_trusted_certificate_add(tls_session, &ca_certificate); + + return(NX_SUCCESS); +} + +static UCHAR tls_packet_buffer[4096]; +static UCHAR tls_packet_buffer_0[4096]; + +void client_thread_entry(ULONG thread_input) +{ +UINT status, topic_length, message_length; +NXD_ADDRESS server_ip; +INT test_result = 0; + + /* Address of remote server. */ + print_error_message( "remote ip address number %lu, remote ip address string %s.\n", REMOTE_IP_ADDRESS_NUMBER, REMOTE_IP_ADDRESS_STRING); + + /* Create MQTT client instance. */ + status = nxd_mqtt_client_create(&mqtt_client, "my_client", CLIENT_ID_STRING, strlen(CLIENT_ID_STRING), + &ip_0, &pool_0, (VOID*)mqtt_client_stack, sizeof(mqtt_client_stack), + MQTT_THREAD_PRIORTY, + (UCHAR*)client_memory, sizeof(client_memory)); + exit_if_fail(NX_SUCCESS == status, TLS_TEST_UNKNOWN_TYPE_ERROR); + + /* Create the second MQTT client instance. */ + status = nxd_mqtt_client_create(&mqtt_client_0, "my_client_0", CLIENT_0_ID_STRING, strlen(CLIENT_0_ID_STRING), + &ip_0, &pool_0, (VOID*)mqtt_client_0_stack, sizeof(mqtt_client_0_stack), + MQTT_THREAD_PRIORTY, + (UCHAR*)client_0_memory, sizeof(client_0_memory)); + exit_if_fail(NX_SUCCESS == status, TLS_TEST_UNKNOWN_TYPE_ERROR); + + /* Create a tls session. */ + status = nx_secure_tls_session_create(&(mqtt_client.nxd_mqtt_tls_session), + &nx_crypto_tls_ciphers, + metadata_buffer, + sizeof(metadata_buffer)); + status += nx_secure_tls_session_packet_buffer_set(&(mqtt_client.nxd_mqtt_tls_session), tls_packet_buffer, sizeof(tls_packet_buffer)); + exit_if_fail(NX_SUCCESS == status, TLS_TEST_UNKNOWN_TYPE_ERROR); + + /* Create a tls session for the second MQTT client instance. */ + status = nx_secure_tls_session_create(&(mqtt_client_0.nxd_mqtt_tls_session), + &nx_crypto_tls_ciphers, + metadata_buffer_0, + sizeof(metadata_buffer_0)); + status += nx_secure_tls_session_packet_buffer_set(&(mqtt_client_0.nxd_mqtt_tls_session), tls_packet_buffer_0, sizeof(tls_packet_buffer_0)); + exit_if_fail(NX_SUCCESS == status, TLS_TEST_UNKNOWN_TYPE_ERROR); + +#ifndef DEBUG_NX_SECURE + /* Wait for the mqtt server. */ + tls_test_semaphore_wait(semaphore_mqtt_server_prepared); + print_error_message( "subscriber get semaphore_server_prepared.\n"); +#endif + + /* Start the connection to the server. */ + server_ip.nxd_ip_version = 4; + server_ip.nxd_ip_address.v4 = REMOTE_IP_ADDRESS_NUMBER; + + /* Connect mqtt server with tls. */ + status = nxd_mqtt_client_secure_connect(&mqtt_client, &server_ip, MQTT_PORT, + tls_setup_method, + MQTT_KEEP_ALIVE_TIMER, 1, NX_WAIT_FOREVER); + exit_if_fail(NX_SUCCESS == status, TLS_TEST_UNKNOWN_TYPE_ERROR); + + /* Subscribe to the topic with QoS level 0. */ + status = nxd_mqtt_client_subscribe(&mqtt_client, TOPIC_NAME, strlen(TOPIC_NAME), QOS0); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + /* So as the second MQTT client instance. */ + status = nxd_mqtt_client_secure_connect(&mqtt_client_0, &server_ip, MQTT_PORT, + tls_setup_method_0, + MQTT_KEEP_ALIVE_TIMER, 1, NX_WAIT_FOREVER); + exit_if_fail(NX_SUCCESS == status, TLS_TEST_UNKNOWN_TYPE_ERROR); + + status = nxd_mqtt_client_subscribe(&mqtt_client_0, TOPIC_NAME, strlen(TOPIC_NAME), QOS0); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + +#ifndef DEBUG_NX_SECURE + /* Post the semaphore to indicate that the given topic is subscribed. */ + tls_test_semaphore_post(semaphore_mqtt_topic_subscribed); + + /* Wait for the publisher. */ + tls_test_semaphore_wait(semaphore_mqtt_message_published); +#endif + + /* Though the publisher put the semaphore, Wait for a moment. */ + tx_thread_sleep(5 * NX_IP_PERIODIC_RATE); + + /* Get MQTT message. */ + status = nxd_mqtt_client_message_get(&mqtt_client, topic_buffer, sizeof(topic_buffer), &topic_length, + message_buffer, sizeof(message_buffer), &message_length); + printf("func: %s, line %d, status = %d.\n", __func__, __LINE__, status); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + /* Verify test result. */ + if(status == NXD_MQTT_SUCCESS) + { + add_error_counter_if_fail( 5 == message_length, test_result); + add_error_counter_if_fail( 'h' == message_buffer[0], test_result); + add_error_counter_if_fail( 'e' == message_buffer[1], test_result); + add_error_counter_if_fail( 'l' == message_buffer[2], test_result); + add_error_counter_if_fail( 'l' == message_buffer[3], test_result); + add_error_counter_if_fail( 'o' == message_buffer[4], test_result); + } + + /* So as the second MQTT client instance. */ + status = nxd_mqtt_client_message_get(&mqtt_client_0, topic_buffer, sizeof(topic_buffer), &topic_length, + message_buffer, sizeof(message_buffer), &message_length); + printf("func: %s, line %d, status = %d.\n", __func__, __LINE__, status); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + /* Verify test result. */ + if(status == NXD_MQTT_SUCCESS) + { + add_error_counter_if_fail( 5 == message_length, test_result); + add_error_counter_if_fail( 'h' == message_buffer[0], test_result); + add_error_counter_if_fail( 'e' == message_buffer[1], test_result); + add_error_counter_if_fail( 'l' == message_buffer[2], test_result); + add_error_counter_if_fail( 'l' == message_buffer[3], test_result); + add_error_counter_if_fail( 'o' == message_buffer[4], test_result); + } + + /* Now unsubscribe the topic. */ + status = nxd_mqtt_client_unsubscribe(&mqtt_client, TOPIC_NAME, strlen(TOPIC_NAME)); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + status = nxd_mqtt_client_unsubscribe(&mqtt_client_0, TOPIC_NAME, strlen(TOPIC_NAME)); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + /* Disconnect from the broker. */ + status = nxd_mqtt_client_disconnect(&mqtt_client); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + status = nxd_mqtt_client_disconnect(&mqtt_client_0); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + /* Delete the client instance, release all the resources. */ + status = nxd_mqtt_client_delete(&mqtt_client); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + status = nxd_mqtt_client_delete(&mqtt_client_0); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + +#ifndef DEBUG_NX_SECURE + /* Post the semaphore to indicate that the test is finished. */ + status = tls_test_semaphore_post(semaphore_mqtt_test_finished); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); +#endif + + exit(test_result); +} +#endif /* ifndef NX_SECURE_ENABLE */ diff --git a/test/regression/interoperability_test/mqtt_test/netx_mqtt_subscriber_empty_message_test.c b/test/regression/interoperability_test/mqtt_test/netx_mqtt_subscriber_empty_message_test.c new file mode 100644 index 00000000..9c30bbff --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/netx_mqtt_subscriber_empty_message_test.c @@ -0,0 +1,195 @@ +#include "mqtt_interoperability_test.h" +#include "nxd_mqtt_client.h" + +#ifdef NXD_MQTT_REQUIRE_TLS +INT mqtt_subscriber_entry(TLS_TEST_INSTANCE* instance_ptr) +{ + print_error_message( "Require TLS.\n"); + return 0; +} +#else /* ifdef NX_SECURE_ENABLE */ +/* Define the ThreadX and NetX object control blocks... */ + +NX_PACKET_POOL pool_0; +NX_IP ip_0; + +NX_TCP_SOCKET tcp_socket; + +#define REMOTE_SERVER_PORT 4433 +#define LOCAL_CLIENT_PORT 30024 + +/* Define the IP thread's stack area. */ +ULONG ip_thread_stack[3 * 1024 / sizeof(ULONG)]; + +/* Define packet pool for the demonstration. */ +#define NX_PACKET_POOL_SIZE ((1536 + sizeof(NX_PACKET)) * 32) +ULONG packet_pool_area[NX_PACKET_POOL_SIZE/sizeof(ULONG) + 64 / sizeof(ULONG)]; + +/* Define the ARP cache area. */ +ULONG arp_space_area[512 / sizeof(ULONG)]; + +/* Define the demo thread. */ +ULONG demo_thread_stack[6 * 1024 / sizeof(ULONG)]; +TX_THREAD demo_thread; + +/* Define the pcap driver function. */ +VOID _nx_pcap_network_driver(NX_IP_DRIVER *driver_req_ptr); + +/* Define a global variable for the pointer of current test instance. */ +TLS_TEST_INSTANCE* client_instance_ptr; +void client_thread_entry(ULONG thread_input); + +/* Declare semaphores. */ +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_server_prepared; +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_topic_subscribed; +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_message_published; +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_test_finished; + +INT mqtt_subscriber_entry(TLS_TEST_INSTANCE* instance_ptr) +{ + client_instance_ptr = instance_ptr; + tx_kernel_enter(); +} + +#ifdef CTEST +VOID test_application_define(void *first_unused_memory) +#else +void tx_application_define(void *first_unused_memory) +#endif +{ +UINT status; + + /* Initialize the NetX system. */ + nx_system_initialize(); + + /* Create a packet pool. */ + status = nx_packet_pool_create(&pool_0, "NetX Main Packet Pool", 1536, (ULONG*)(((int)packet_pool_area + 64) & ~63) , NX_PACKET_POOL_SIZE); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Create an IP instance. */ + status = nx_ip_create(&ip_0, + "NetX IP Instance 0", + TLS_TEST_IP_ADDRESS_NUMBER, + 0xFFFFFF00UL, + &pool_0, + _nx_pcap_network_driver, + (UCHAR*)ip_thread_stack, + sizeof(ip_thread_stack), + 1); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Enable ARP and supply ARP cache memory for IP Instance 0. */ + status = nx_arp_enable(&ip_0, (void *)arp_space_area, sizeof(arp_space_area)); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Enable TCP traffic. */ + status = nx_tcp_enable(&ip_0); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Enable UDP traffic. */ + status = nx_udp_enable(&ip_0); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Enable ICMP. */ + status = nx_icmp_enable(&ip_0); + show_error_message_if_fail(NX_SUCCESS == status); + + status = nx_ip_fragment_enable(&ip_0); + show_error_message_if_fail(NX_SUCCESS == status); + tx_thread_create(&demo_thread, "demo thread", client_thread_entry, 0, + demo_thread_stack, sizeof(demo_thread_stack), + 16, 16, 4, TX_AUTO_START); +} + +/* Declare the MQTT client control block. */ +static NXD_MQTT_CLIENT mqtt_client; +#define CLIENT_ID_STRING "mytestclient" +#define MQTT_CLIENT_STACK_SIZE 4096 + +/* Define the priority of the MQTT internal thread. */ +#define MQTT_THREAD_PRIORTY 2 + +/* Declare a 2000-byte memory space the application supplies to the MQTT client instance. */ +static ULONG client_memory[2000 / sizeof(ULONG)]; + +/* Declare the MQTT thread stack space. */ +static ULONG mqtt_client_stack[MQTT_CLIENT_STACK_SIZE / sizeof(ULONG)]; + +/* Define the MQTT keep alive timer for 5 minutes */ +#define MQTT_KEEP_ALIVE_TIMER 300 + +/* Define the subscribed topic. */ +#define TOPIC_NAME "test" + +#define QOS0 0 +#define QOS1 1 + +/* Declare buffers to hold message and topic. */ +static UCHAR message_buffer[NXD_MQTT_MAX_MESSAGE_LENGTH]; +static UCHAR topic_buffer[NXD_MQTT_MAX_TOPIC_NAME_LENGTH]; + +void client_thread_entry(ULONG thread_input) +{ +UINT status, topic_length, message_length = 0xFFFFFFFF; +NXD_ADDRESS server_ip; +INT test_result = 0; + + /* Address of remote server. */ + print_error_message( "remote ip address number %lu, remote ip address string %s.\n", REMOTE_IP_ADDRESS_NUMBER, REMOTE_IP_ADDRESS_STRING); + + /* Create MQTT client instance. */ + status = nxd_mqtt_client_create(&mqtt_client, "my_client", CLIENT_ID_STRING, strlen(CLIENT_ID_STRING), + &ip_0, &pool_0, (VOID*)mqtt_client_stack, sizeof(mqtt_client_stack), + MQTT_THREAD_PRIORTY, + (UCHAR*)client_memory, sizeof(client_memory)); + exit_if_fail(NX_SUCCESS == status, TLS_TEST_UNKNOWN_TYPE_ERROR); + + /* Wait for the mqtt server. */ + tls_test_semaphore_wait(semaphore_mqtt_server_prepared); + print_error_message( "subscriber get semaphore_server_prepared.\n"); + + /* Start the connection to the server. */ + server_ip.nxd_ip_version = 4; + server_ip.nxd_ip_address.v4 = REMOTE_IP_ADDRESS_NUMBER; + status = nxd_mqtt_client_connect(&mqtt_client, &server_ip, MQTT_PORT, + MQTT_KEEP_ALIVE_TIMER, 0, NX_WAIT_FOREVER); + exit_if_fail(NX_SUCCESS == status, TLS_TEST_UNKNOWN_TYPE_ERROR); + + /* Subscribe to the topic with QoS level 0. */ + status = nxd_mqtt_client_subscribe(&mqtt_client, TOPIC_NAME, strlen(TOPIC_NAME), QOS0); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + /* Post the semaphore to indicate that the given topic is subscribed. */ + tls_test_semaphore_post(semaphore_mqtt_topic_subscribed); + + /* Wait for the publisher. */ + tls_test_semaphore_wait(semaphore_mqtt_message_published); + status = nxd_mqtt_client_message_get(&mqtt_client, topic_buffer, sizeof(topic_buffer), &topic_length, + message_buffer, sizeof(message_buffer), &message_length); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + /* Verify test result. */ + if(status == NXD_MQTT_SUCCESS) + { + add_error_counter_if_fail( 0 == message_length, test_result); + } + + /* Now unsubscribe the topic. */ + status = nxd_mqtt_client_unsubscribe(&mqtt_client, TOPIC_NAME, strlen(TOPIC_NAME)); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + /* Disconnect from the broker. */ + status = nxd_mqtt_client_disconnect(&mqtt_client); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + /* Delete the client instance, release all the resources. */ + status = nxd_mqtt_client_delete(&mqtt_client); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + /* Post the semaphore to indicate that the test is finished. */ + status = tls_test_semaphore_post(semaphore_mqtt_test_finished); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + exit(test_result); +} +#endif diff --git a/test/regression/interoperability_test/mqtt_test/netx_mqtt_subscriber_test.c b/test/regression/interoperability_test/mqtt_test/netx_mqtt_subscriber_test.c new file mode 100644 index 00000000..799bffd4 --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/netx_mqtt_subscriber_test.c @@ -0,0 +1,200 @@ +#include "mqtt_interoperability_test.h" +#include "nxd_mqtt_client.h" + +#ifdef NXD_MQTT_REQUIRE_TLS +INT mqtt_subscriber_entry(TLS_TEST_INSTANCE* instance_ptr) +{ + print_error_message( "Require TLS.\n"); + return 0; +} +#else /* ifdef NX_SECURE_ENABLE */ +/* Define the ThreadX and NetX object control blocks... */ + +NX_PACKET_POOL pool_0; +NX_IP ip_0; + +NX_TCP_SOCKET tcp_socket; + +#define REMOTE_SERVER_PORT 4433 +#define LOCAL_CLIENT_PORT 30024 + +/* Define the IP thread's stack area. */ +ULONG ip_thread_stack[3 * 1024 / sizeof(ULONG)]; + +/* Define packet pool for the demonstration. */ +#define NX_PACKET_POOL_SIZE ((1536 + sizeof(NX_PACKET)) * 32) +ULONG packet_pool_area[NX_PACKET_POOL_SIZE/sizeof(ULONG) + 64 / sizeof(ULONG)]; + +/* Define the ARP cache area. */ +ULONG arp_space_area[512 / sizeof(ULONG)]; + +/* Define the demo thread. */ +ULONG demo_thread_stack[6 * 1024 / sizeof(ULONG)]; +TX_THREAD demo_thread; + +/* Define the pcap driver function. */ +VOID _nx_pcap_network_driver(NX_IP_DRIVER *driver_req_ptr); + +/* Define a global variable for the pointer of current test instance. */ +TLS_TEST_INSTANCE* client_instance_ptr; +void client_thread_entry(ULONG thread_input); + +/* Declare semaphores. */ +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_server_prepared; +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_topic_subscribed; +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_message_published; +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_test_finished; + +INT mqtt_subscriber_entry(TLS_TEST_INSTANCE* instance_ptr) +{ + client_instance_ptr = instance_ptr; + tx_kernel_enter(); +} + +#ifdef CTEST +VOID test_application_define(void *first_unused_memory) +#else +void tx_application_define(void *first_unused_memory) +#endif +{ +UINT status; + + /* Initialize the NetX system. */ + nx_system_initialize(); + + /* Create a packet pool. */ + status = nx_packet_pool_create(&pool_0, "NetX Main Packet Pool", 1536, (ULONG*)(((int)packet_pool_area + 64) & ~63) , NX_PACKET_POOL_SIZE); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Create an IP instance. */ + status = nx_ip_create(&ip_0, + "NetX IP Instance 0", + TLS_TEST_IP_ADDRESS_NUMBER, + 0xFFFFFF00UL, + &pool_0, + _nx_pcap_network_driver, + (UCHAR*)ip_thread_stack, + sizeof(ip_thread_stack), + 1); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Enable ARP and supply ARP cache memory for IP Instance 0. */ + status = nx_arp_enable(&ip_0, (void *)arp_space_area, sizeof(arp_space_area)); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Enable TCP traffic. */ + status = nx_tcp_enable(&ip_0); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Enable UDP traffic. */ + status = nx_udp_enable(&ip_0); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Enable ICMP. */ + status = nx_icmp_enable(&ip_0); + show_error_message_if_fail(NX_SUCCESS == status); + + status = nx_ip_fragment_enable(&ip_0); + show_error_message_if_fail(NX_SUCCESS == status); + tx_thread_create(&demo_thread, "demo thread", client_thread_entry, 0, + demo_thread_stack, sizeof(demo_thread_stack), + 16, 16, 4, TX_AUTO_START); +} + +/* Declare the MQTT client control block. */ +static NXD_MQTT_CLIENT mqtt_client; +#define CLIENT_ID_STRING "mytestclient" +#define MQTT_CLIENT_STACK_SIZE 4096 + +/* Define the priority of the MQTT internal thread. */ +#define MQTT_THREAD_PRIORTY 2 + +/* Declare a 2000-byte memory space the application supplies to the MQTT client instance. */ +static ULONG client_memory[2000 / sizeof(ULONG)]; + +/* Declare the MQTT thread stack space. */ +static ULONG mqtt_client_stack[MQTT_CLIENT_STACK_SIZE / sizeof(ULONG)]; + +/* Define the MQTT keep alive timer for 5 minutes */ +#define MQTT_KEEP_ALIVE_TIMER 300 + +/* Define the subscribed topic. */ +#define TOPIC_NAME "test" + +#define QOS0 0 +#define QOS1 1 + +/* Declare buffers to hold message and topic. */ +static UCHAR message_buffer[NXD_MQTT_MAX_MESSAGE_LENGTH]; +static UCHAR topic_buffer[NXD_MQTT_MAX_TOPIC_NAME_LENGTH]; + +void client_thread_entry(ULONG thread_input) +{ +UINT status, topic_length, message_length; +NXD_ADDRESS server_ip; +INT test_result = 0; + + /* Address of remote server. */ + print_error_message( "remote ip address number %lu, remote ip address string %s.\n", REMOTE_IP_ADDRESS_NUMBER, REMOTE_IP_ADDRESS_STRING); + + /* Create MQTT client instance. */ + status = nxd_mqtt_client_create(&mqtt_client, "my_client", CLIENT_ID_STRING, strlen(CLIENT_ID_STRING), + &ip_0, &pool_0, (VOID*)mqtt_client_stack, sizeof(mqtt_client_stack), + MQTT_THREAD_PRIORTY, + (UCHAR*)client_memory, sizeof(client_memory)); + exit_if_fail(NX_SUCCESS == status, TLS_TEST_UNKNOWN_TYPE_ERROR); + + /* Wait for the mqtt server. */ + tls_test_semaphore_wait(semaphore_mqtt_server_prepared); + print_error_message( "subscriber get semaphore_server_prepared.\n"); + + /* Start the connection to the server. */ + server_ip.nxd_ip_version = 4; + server_ip.nxd_ip_address.v4 = REMOTE_IP_ADDRESS_NUMBER; + status = nxd_mqtt_client_connect(&mqtt_client, &server_ip, MQTT_PORT, + MQTT_KEEP_ALIVE_TIMER, 0, NX_WAIT_FOREVER); + exit_if_fail(NX_SUCCESS == status, TLS_TEST_UNKNOWN_TYPE_ERROR); + + /* Subscribe to the topic with QoS level 0. */ + status = nxd_mqtt_client_subscribe(&mqtt_client, TOPIC_NAME, strlen(TOPIC_NAME), QOS0); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + /* Post the semaphore to indicate that the given topic is subscribed. */ + tls_test_semaphore_post(semaphore_mqtt_topic_subscribed); + + /* Wait for the publisher. */ + tls_test_semaphore_wait(semaphore_mqtt_message_published); + status = nxd_mqtt_client_message_get(&mqtt_client, topic_buffer, sizeof(topic_buffer), &topic_length, + message_buffer, sizeof(message_buffer), &message_length); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + /* Verify test result. */ + if(status == NXD_MQTT_SUCCESS) + { + add_error_counter_if_fail( 5 == message_length, test_result); + add_error_counter_if_fail( 'h' == message_buffer[0], test_result); + add_error_counter_if_fail( 'e' == message_buffer[1], test_result); + add_error_counter_if_fail( 'l' == message_buffer[2], test_result); + add_error_counter_if_fail( 'l' == message_buffer[3], test_result); + add_error_counter_if_fail( 'o' == message_buffer[4], test_result); + } + + /* Now unsubscribe the topic. */ + status = nxd_mqtt_client_unsubscribe(&mqtt_client, TOPIC_NAME, strlen(TOPIC_NAME)); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + /* Disconnect from the broker. */ + status = nxd_mqtt_client_disconnect(&mqtt_client); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + /* Delete the client instance, release all the resources. */ + status = nxd_mqtt_client_delete(&mqtt_client); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + /* Post the semaphore to indicate that the test is finished. */ + status = tls_test_semaphore_post(semaphore_mqtt_test_finished); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + exit(test_result); +} +#endif diff --git a/test/regression/interoperability_test/mqtt_test/netx_mqtt_tls_subscriber_test.c b/test/regression/interoperability_test/mqtt_test/netx_mqtt_tls_subscriber_test.c new file mode 100644 index 00000000..4bd5f859 --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/netx_mqtt_tls_subscriber_test.c @@ -0,0 +1,269 @@ +#include "mqtt_interoperability_test.h" +#include "ca.c" + +#ifndef NX_SECURE_ENABLE +INT mqtt_subscriber_entry(TLS_TEST_INSTANCE* instance_ptr) +{ + print_error_message( "NX_SEUCRE_ENABLE is not defined.\n"); + return 0; +} +#else /* ifdef NX_SECURE_ENABLE */ + +#include "nxd_mqtt_client.h" + +/* Define the ThreadX and NetX object control blocks... */ + +NX_PACKET_POOL pool_0; +NX_IP ip_0; + +NX_TCP_SOCKET tcp_socket; + +#define REMOTE_SERVER_PORT 4433 +#define LOCAL_CLIENT_PORT 30024 + +/* Define the IP thread's stack area. */ +ULONG ip_thread_stack[3 * 1024 / sizeof(ULONG)]; + +/* Define packet pool for the demonstration. */ +#define NX_PACKET_POOL_SIZE ((1536 + sizeof(NX_PACKET)) * 64) +ULONG packet_pool_area[NX_PACKET_POOL_SIZE/sizeof(ULONG) + 64 / sizeof(ULONG)]; + +/* Define the ARP cache area. */ +ULONG arp_space_area[512 / sizeof(ULONG)]; + +/* Define the demo thread. */ +ULONG demo_thread_stack[6 * 1024 / sizeof(ULONG)]; +TX_THREAD demo_thread; + +/* Define the pcap driver function. */ +VOID _nx_pcap_network_driver(NX_IP_DRIVER *driver_req_ptr); + +/* Define a global variable for the pointer of current test instance. */ +TLS_TEST_INSTANCE* client_instance_ptr; +void client_thread_entry(ULONG thread_input); + +#ifdef DEBUG_NX_SECURE +INT main() +{ + tx_kernel_enter(); +} +#else +/* Declare semaphores. */ +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_server_prepared; +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_topic_subscribed; +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_message_published; +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_test_finished; + +INT mqtt_subscriber_entry(TLS_TEST_INSTANCE* instance_ptr) +{ + client_instance_ptr = instance_ptr; + tx_kernel_enter(); +} +#endif + +#ifdef CTEST +VOID test_application_define(void *first_unused_memory) +#else +void tx_application_define(void *first_unused_memory) +#endif +{ +UINT status; + + /* Initialize the NetX system. */ + nx_system_initialize(); + + /* Create a packet pool. */ + status = nx_packet_pool_create(&pool_0, "NetX Main Packet Pool", 1536, (ULONG*)(((int)packet_pool_area + 64) & ~63) , NX_PACKET_POOL_SIZE); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Create an IP instance. */ + status = nx_ip_create(&ip_0, + "NetX IP Instance 0", + TLS_TEST_IP_ADDRESS_NUMBER, + 0xFFFFFF00UL, + &pool_0, + _nx_pcap_network_driver, + (UCHAR*)ip_thread_stack, + sizeof(ip_thread_stack), + 1); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Enable ARP and supply ARP cache memory for IP Instance 0. */ + status = nx_arp_enable(&ip_0, (void *)arp_space_area, sizeof(arp_space_area)); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Enable TCP traffic. */ + status = nx_tcp_enable(&ip_0); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Enable UDP traffic. */ + status = nx_udp_enable(&ip_0); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Enable ICMP. */ + status = nx_icmp_enable(&ip_0); + show_error_message_if_fail(NX_SUCCESS == status); + + status = nx_ip_fragment_enable(&ip_0); + show_error_message_if_fail(NX_SUCCESS == status); + tx_thread_create(&demo_thread, "demo thread", client_thread_entry, 0, + demo_thread_stack, sizeof(demo_thread_stack), + 16, 16, 4, TX_AUTO_START); +} + +/* Declare the MQTT client control block. */ +static NXD_MQTT_CLIENT mqtt_client; +#define CLIENT_ID_STRING "mytestclient" +#define MQTT_CLIENT_STACK_SIZE 4096 + +/* Define the priority of the MQTT internal thread. */ +#define MQTT_THREAD_PRIORTY 2 + +/* Declare a 2000-byte memory space the application supplies to the MQTT client instance. */ +static ULONG client_memory[2000 / sizeof(ULONG)]; + +/* Declare the MQTT thread stack space. */ +static ULONG mqtt_client_stack[MQTT_CLIENT_STACK_SIZE / sizeof(ULONG)]; + +/* Define the MQTT keep alive timer for 5 minutes */ +#define MQTT_KEEP_ALIVE_TIMER 300 + +/* Define the subscribed topic. */ +#define TOPIC_NAME "test" + +#define QOS0 0 +#define QOS1 1 + +/* Declare external cryptosuites. */ +extern const NX_SECURE_TLS_CRYPTO nx_crypto_tls_ciphers; + +/* Define crypto metadata buffer. */ +static UCHAR metadata_buffer[5*4096]; + +/* Declare buffers to hold message and topic. */ +static UCHAR message_buffer[NXD_MQTT_MAX_MESSAGE_LENGTH]; +static UCHAR topic_buffer[NXD_MQTT_MAX_TOPIC_NAME_LENGTH]; + +/* For remote certificate. */ +NX_SECURE_X509_CERT remote_certificate, remote_issuer, ca_certificate; +UCHAR remote_cert_buffer[2000]; +UCHAR remote_issuer_buffer[2000]; +static UCHAR tls_packet_buffer[4096]; + +/* Define the TLS setup fail function for tls connection. */ +UINT tls_setup_fail(NXD_MQTT_CLIENT* client_ptr, NX_SECURE_TLS_SESSION* tls_session, + NX_SECURE_X509_CERT* certificate, NX_SECURE_X509_CERT* trusted_certificate) +{ + return 1; +} + +/* Define the callback function for tls connection. */ +UINT tls_setup_method(NXD_MQTT_CLIENT* client_ptr, NX_SECURE_TLS_SESSION* tls_session, + NX_SECURE_X509_CERT* certificate, NX_SECURE_X509_CERT* trusted_certificate) +{ + + /* Create a tls session. */ + if (nx_secure_tls_session_create(tls_session, + &nx_crypto_tls_ciphers, + metadata_buffer, + sizeof(metadata_buffer))) + { + return 1; + } + + nx_secure_tls_session_packet_buffer_set(tls_session, tls_packet_buffer, sizeof(tls_packet_buffer)); + nx_secure_tls_remote_certificate_allocate(tls_session, &remote_certificate, remote_cert_buffer, sizeof(remote_cert_buffer)); + nx_secure_tls_remote_certificate_allocate(tls_session, &remote_issuer, remote_issuer_buffer, sizeof(remote_issuer_buffer)); + + nx_secure_x509_certificate_initialize(&ca_certificate, ca_der, ca_der_len, + NX_NULL, 0, NX_NULL, 0, NX_SECURE_X509_KEY_TYPE_NONE); + nx_secure_tls_trusted_certificate_add(tls_session, &ca_certificate); + + return(NX_SUCCESS); +} + +void client_thread_entry(ULONG thread_input) +{ +UINT status, topic_length, message_length; +NXD_ADDRESS server_ip; +INT test_result = 0; + + /* Address of remote server. */ + print_error_message( "remote ip address number %lu, remote ip address string %s.\n", REMOTE_IP_ADDRESS_NUMBER, REMOTE_IP_ADDRESS_STRING); + + /* Create MQTT client instance. */ + status = nxd_mqtt_client_create(&mqtt_client, "my_client", CLIENT_ID_STRING, strlen(CLIENT_ID_STRING), + &ip_0, &pool_0, (VOID*)mqtt_client_stack, sizeof(mqtt_client_stack), + MQTT_THREAD_PRIORTY, + (UCHAR*)client_memory, sizeof(client_memory)); + exit_if_fail(NX_SUCCESS == status, TLS_TEST_UNKNOWN_TYPE_ERROR); + +#ifndef DEBUG_NX_SECURE + /* Wait for the mqtt server. */ + tls_test_semaphore_wait(semaphore_mqtt_server_prepared); + print_error_message( "subscriber get semaphore_server_prepared.\n"); +#endif + + /* Start the connection to the server. */ + server_ip.nxd_ip_version = 4; + server_ip.nxd_ip_address.v4 = REMOTE_IP_ADDRESS_NUMBER; + + /* Test TLS setup fail. */ + status = nxd_mqtt_client_secure_connect(&mqtt_client, &server_ip, MQTT_PORT, + tls_setup_fail, + MQTT_KEEP_ALIVE_TIMER, 1, NX_WAIT_FOREVER); + exit_if_fail(1 == status, TLS_TEST_UNKNOWN_TYPE_ERROR); + + /* Connect mqtt server with tls. */ + status = nxd_mqtt_client_secure_connect(&mqtt_client, &server_ip, MQTT_PORT, + tls_setup_method, + MQTT_KEEP_ALIVE_TIMER, 1, NX_WAIT_FOREVER); + exit_if_fail(NX_SUCCESS == status, TLS_TEST_UNKNOWN_TYPE_ERROR); + + /* Subscribe to the topic with QoS level 0. */ + status = nxd_mqtt_client_subscribe(&mqtt_client, TOPIC_NAME, strlen(TOPIC_NAME), QOS0); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + +#ifndef DEBUG_NX_SECURE + /* Post the semaphore to indicate that the given topic is subscribed. */ + tls_test_semaphore_post(semaphore_mqtt_topic_subscribed); + + /* Wait for the publisher. */ + tls_test_semaphore_wait(semaphore_mqtt_message_published); +#endif + status = nxd_mqtt_client_message_get(&mqtt_client, topic_buffer, sizeof(topic_buffer), &topic_length, + message_buffer, sizeof(message_buffer), &message_length); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + /* Verify test result. */ + if(status == NXD_MQTT_SUCCESS) + { + add_error_counter_if_fail( 5 == message_length, test_result); + add_error_counter_if_fail( 'h' == message_buffer[0], test_result); + add_error_counter_if_fail( 'e' == message_buffer[1], test_result); + add_error_counter_if_fail( 'l' == message_buffer[2], test_result); + add_error_counter_if_fail( 'l' == message_buffer[3], test_result); + add_error_counter_if_fail( 'o' == message_buffer[4], test_result); + } + + /* Now unsubscribe the topic. */ + status = nxd_mqtt_client_unsubscribe(&mqtt_client, TOPIC_NAME, strlen(TOPIC_NAME)); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + /* Disconnect from the broker. */ + status = nxd_mqtt_client_disconnect(&mqtt_client); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + /* Delete the client instance, release all the resources. */ + status = nxd_mqtt_client_delete(&mqtt_client); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + +#ifndef DEBUG_NX_SECURE + /* Post the semaphore to indicate that the test is finished. */ + status = tls_test_semaphore_post(semaphore_mqtt_test_finished); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); +#endif + + exit(test_result); +} +#endif /* ifndef NX_SECURE_ENABLE */ diff --git a/test/regression/interoperability_test/mqtt_test/netx_mqtt_tls_subscriber_twice_test.c b/test/regression/interoperability_test/mqtt_test/netx_mqtt_tls_subscriber_twice_test.c new file mode 100644 index 00000000..b46865bb --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/netx_mqtt_tls_subscriber_twice_test.c @@ -0,0 +1,284 @@ +#include "mqtt_interoperability_test.h" +#include "ca.c" + +#ifndef NX_SECURE_ENABLE +INT mqtt_subscriber_entry(TLS_TEST_INSTANCE* instance_ptr) +{ + print_error_message( "NX_SEUCRE_ENABLE is not defined.\n"); + return 0; +} +#else /* ifdef NX_SECURE_ENABLE */ + +#include "nxd_mqtt_client.h" + +/* Define the ThreadX and NetX object control blocks... */ + +NX_PACKET_POOL pool_0; +NX_IP ip_0; + +NX_TCP_SOCKET tcp_socket; + +#define REMOTE_SERVER_PORT 4433 +#define LOCAL_CLIENT_PORT 30024 + +/* Define the IP thread's stack area. */ +ULONG ip_thread_stack[3 * 1024 / sizeof(ULONG)]; + +/* Define packet pool for the demonstration. */ +#define NX_PACKET_POOL_SIZE ((1536 + sizeof(NX_PACKET)) * 64) +ULONG packet_pool_area[NX_PACKET_POOL_SIZE/sizeof(ULONG) + 64 / sizeof(ULONG)]; + +/* Define the ARP cache area. */ +ULONG arp_space_area[512 / sizeof(ULONG)]; + +/* Define the demo thread. */ +ULONG demo_thread_stack[6 * 1024 / sizeof(ULONG)]; +TX_THREAD demo_thread; + +/* Define the pcap driver function. */ +VOID _nx_pcap_network_driver(NX_IP_DRIVER *driver_req_ptr); + +/* Define a global variable for the pointer of current test instance. */ +TLS_TEST_INSTANCE* client_instance_ptr; +void client_thread_entry(ULONG thread_input); + +#ifdef DEBUG_NX_SECURE +INT main() +{ + tx_kernel_enter(); +} +#else +/* Declare semaphores. */ +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_server_prepared; +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_topic_subscribed; +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_message_published; +extern TLS_TEST_SEMAPHORE* semaphore_mqtt_test_finished; + +INT mqtt_subscriber_entry(TLS_TEST_INSTANCE* instance_ptr) +{ + client_instance_ptr = instance_ptr; + tx_kernel_enter(); +} +#endif + +#ifdef CTEST +VOID test_application_define(void *first_unused_memory) +#else +void tx_application_define(void *first_unused_memory) +#endif +{ +UINT status; + + /* Initialize the NetX system. */ + nx_system_initialize(); + + /* Create a packet pool. */ + status = nx_packet_pool_create(&pool_0, "NetX Main Packet Pool", 1536, (ULONG*)(((int)packet_pool_area + 64) & ~63) , NX_PACKET_POOL_SIZE); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Create an IP instance. */ + status = nx_ip_create(&ip_0, + "NetX IP Instance 0", + TLS_TEST_IP_ADDRESS_NUMBER, + 0xFFFFFF00UL, + &pool_0, + _nx_pcap_network_driver, + (UCHAR*)ip_thread_stack, + sizeof(ip_thread_stack), + 1); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Enable ARP and supply ARP cache memory for IP Instance 0. */ + status = nx_arp_enable(&ip_0, (void *)arp_space_area, sizeof(arp_space_area)); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Enable TCP traffic. */ + status = nx_tcp_enable(&ip_0); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Enable UDP traffic. */ + status = nx_udp_enable(&ip_0); + show_error_message_if_fail(NX_SUCCESS == status); + + /* Enable ICMP. */ + status = nx_icmp_enable(&ip_0); + show_error_message_if_fail(NX_SUCCESS == status); + + status = nx_ip_fragment_enable(&ip_0); + show_error_message_if_fail(NX_SUCCESS == status); + tx_thread_create(&demo_thread, "demo thread", client_thread_entry, 0, + demo_thread_stack, sizeof(demo_thread_stack), + 16, 16, 4, TX_AUTO_START); +} + +/* Declare the MQTT client control block. */ +static NXD_MQTT_CLIENT mqtt_client; +#define CLIENT_ID_STRING "mytestclient" +#define MQTT_CLIENT_STACK_SIZE 4096 + +/* Define the priority of the MQTT internal thread. */ +#define MQTT_THREAD_PRIORTY 2 + +/* Declare a 2000-byte memory space the application supplies to the MQTT client instance. */ +static ULONG client_memory[2000 / sizeof(ULONG)]; + +/* Declare the MQTT thread stack space. */ +static ULONG mqtt_client_stack[MQTT_CLIENT_STACK_SIZE / sizeof(ULONG)]; + +/* Define the MQTT keep alive timer for 5 minutes */ +#define MQTT_KEEP_ALIVE_TIMER 300 + +/* Define the subscribed topic. */ +#define TOPIC_NAME "test" + +#define QOS0 0 +#define QOS1 1 + +/* Declare external cryptosuites. */ +extern const NX_SECURE_TLS_CRYPTO nx_crypto_tls_ciphers; + +/* Define crypto metadata buffer. */ +static UCHAR metadata_buffer[5*4096]; + +/* Declare buffers to hold message and topic. */ +static UCHAR message_buffer[NXD_MQTT_MAX_MESSAGE_LENGTH]; +static UCHAR topic_buffer[NXD_MQTT_MAX_TOPIC_NAME_LENGTH]; + +/* For remote certificate. */ +NX_SECURE_X509_CERT remote_certificate, remote_issuer, ca_certificate; +UCHAR remote_cert_buffer[2000]; +UCHAR remote_issuer_buffer[2000]; +static UCHAR tls_packet_buffer[4096]; +static UINT error_counter; + +/* Define the callback function for tls connection. */ +UINT tls_setup_method(NXD_MQTT_CLIENT* client_ptr, NX_SECURE_TLS_SESSION* tls_session, + NX_SECURE_X509_CERT* certificate, NX_SECURE_X509_CERT* trusted_certificate) +{ + + /* Create a tls session. */ + if (nx_secure_tls_session_create(tls_session, + &nx_crypto_tls_ciphers, + metadata_buffer, + sizeof(metadata_buffer))) + { + error_counter++; + return 1; + } + + nx_secure_tls_session_packet_buffer_set(tls_session, tls_packet_buffer, sizeof(tls_packet_buffer)); + nx_secure_tls_remote_certificate_allocate(tls_session, &remote_certificate, remote_cert_buffer, sizeof(remote_cert_buffer)); + nx_secure_tls_remote_certificate_allocate(tls_session, &remote_issuer, remote_issuer_buffer, sizeof(remote_issuer_buffer)); + + nx_secure_x509_certificate_initialize(&ca_certificate, ca_der, ca_der_len, + NX_NULL, 0, NX_NULL, 0, NX_SECURE_X509_KEY_TYPE_NONE); + nx_secure_tls_trusted_certificate_add(tls_session, &ca_certificate); + + return(NX_SUCCESS); +} + +void client_thread_entry(ULONG thread_input) +{ +UINT status, topic_length, message_length; +NXD_ADDRESS server_ip; +INT test_result = 0; +UINT i; + + /* Address of remote server. */ + print_error_message( "remote ip address number %lu, remote ip address string %s.\n", REMOTE_IP_ADDRESS_NUMBER, REMOTE_IP_ADDRESS_STRING); + + /* Create MQTT client instance. */ + status = nxd_mqtt_client_create(&mqtt_client, "my_client", CLIENT_ID_STRING, strlen(CLIENT_ID_STRING), + &ip_0, &pool_0, (VOID*)mqtt_client_stack, sizeof(mqtt_client_stack), + MQTT_THREAD_PRIORTY, + (UCHAR*)client_memory, sizeof(client_memory)); + exit_if_fail(NX_SUCCESS == status, TLS_TEST_UNKNOWN_TYPE_ERROR); + +#ifndef DEBUG_NX_SECURE + /* Wait for the mqtt server. */ + tls_test_semaphore_wait(semaphore_mqtt_server_prepared); + print_error_message( "subscriber get semaphore_server_prepared.\n"); +#endif + + error_counter = 0; + for (i = 0; i < 4; i++) + { + + if (i == 0) + { + + /* Start the connection to the server. */ + server_ip.nxd_ip_version = 4; + server_ip.nxd_ip_address.v4 = 0x7F000001; + + /* Connect mqtt server with tls to port not bound. */ + status = nxd_mqtt_client_secure_connect(&mqtt_client, &server_ip, 443, + tls_setup_method, + MQTT_KEEP_ALIVE_TIMER, 1, NX_WAIT_FOREVER); + exit_if_fail(NX_SUCCESS != status, TLS_TEST_UNKNOWN_TYPE_ERROR); + continue; + } + else + { + + /* Start the connection to the server. */ + server_ip.nxd_ip_version = 4; + server_ip.nxd_ip_address.v4 = REMOTE_IP_ADDRESS_NUMBER; + + /* Connect mqtt server with tls. */ + status = nxd_mqtt_client_secure_connect(&mqtt_client, &server_ip, MQTT_PORT, + tls_setup_method, + MQTT_KEEP_ALIVE_TIMER, 1, NX_WAIT_FOREVER); + exit_if_fail(NX_SUCCESS == status, TLS_TEST_UNKNOWN_TYPE_ERROR); + } + + /* Subscribe to the topic with QoS level 0. */ + status = nxd_mqtt_client_subscribe(&mqtt_client, TOPIC_NAME, strlen(TOPIC_NAME), QOS0); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + +#ifndef DEBUG_NX_SECURE + /* Post the semaphore to indicate that the given topic is subscribed. */ + tls_test_semaphore_post(semaphore_mqtt_topic_subscribed); + + /* Wait for the publisher. */ + tls_test_semaphore_wait(semaphore_mqtt_message_published); +#endif + status = nxd_mqtt_client_message_get(&mqtt_client, topic_buffer, sizeof(topic_buffer), &topic_length, + message_buffer, sizeof(message_buffer), &message_length); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + /* Verify test result. */ + if(status == NXD_MQTT_SUCCESS) + { + add_error_counter_if_fail( 5 == message_length, test_result); + add_error_counter_if_fail( 'h' == message_buffer[0], test_result); + add_error_counter_if_fail( 'e' == message_buffer[1], test_result); + add_error_counter_if_fail( 'l' == message_buffer[2], test_result); + add_error_counter_if_fail( 'l' == message_buffer[3], test_result); + add_error_counter_if_fail( 'o' == message_buffer[4], test_result); + } + + /* Now unsubscribe the topic. */ + status = nxd_mqtt_client_unsubscribe(&mqtt_client, TOPIC_NAME, strlen(TOPIC_NAME)); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + /* Disconnect from the broker. */ + status = nxd_mqtt_client_disconnect(&mqtt_client); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + + add_error_counter_if_fail(error_counter == 0, test_result); + } + + /* Delete the client instance, release all the resources. */ + status = nxd_mqtt_client_delete(&mqtt_client); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); + +#ifndef DEBUG_NX_SECURE + /* Post the semaphore to indicate that the test is finished. */ + status = tls_test_semaphore_post(semaphore_mqtt_test_finished); + add_error_counter_if_fail(NX_SUCCESS == status, test_result); +#endif + + exit(test_result); +} +#endif /* ifndef NX_SECURE_ENABLE */ diff --git a/test/regression/interoperability_test/mqtt_test/test_scripts/CA/ca/ca.crt b/test/regression/interoperability_test/mqtt_test/test_scripts/CA/ca/ca.crt new file mode 100644 index 00000000..f2a0500b --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/test_scripts/CA/ca/ca.crt @@ -0,0 +1,35 @@ +-----BEGIN CERTIFICATE----- +MIIF/jCCA+agAwIBAgIBATANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx +EzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDVNhbiBGcmFuY2lzY28xEzAR +BgNVBAoMCkJvZ3VzIEluYy4xEzARBgNVBAsMCk9wZXJhdGlvbnMxKTAnBgNVBAMM +IEJvZ3VzIEluYy4gQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4XDTE3MDMwODA0NDA1 +OVoXDTI3MDMwODA0NDA1OVowgY8xCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxp +Zm9ybmlhMRYwFAYDVQQHDA1TYW4gRnJhbmNpc2NvMRMwEQYDVQQKDApCb2d1cyBJ +bmMuMRMwEQYDVQQLDApPcGVyYXRpb25zMSkwJwYDVQQDDCBCb2d1cyBJbmMuIENl +cnRpZmljYXRlIEF1dGhvcml0eTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC +ggIBALZgiFvJEh0ra1FiYuWUEkP6JyWkPZEYRTRD+llle8P1dJym9YCR8B07fftr +TETbBopKfj8brndhW2ZhNUl32U8budFdI0iPH/H1Y4zR56Wom5xizpIJ1MTfT3Ja +Q7m89ezihfphcsECxXqVbgPFKceWOfhOxHzHNT2dt1No7/psGKQ/F5LcGmEBdTyp +fmytvopijuiiqcUK8Q7z/9MpyHTNfO3mvp/JhTvkYyjS6Tj23ywZAbehXYUVRGIO +AME3bbzcyke0Uhcbo8wZrtlzx1t24d4QTvkC4Wg6EFFbDnxEG2QlqaGfSCo1FQs2 +g/ffYpV0Md0b/euChMtd+HHDeDDpuC/nWdLrmAPQFwOIxGtsFFyVGMC/QpX+I7ML +bEZZyBEnxloJRQk/I/DZXUlAldqficqEevJJDUOii2gWLdz/1YL8P2+3mDTbvgvq +KmT6mQw5BeaLm9FuHJoZD966rjO+iI4aUZ8mu4etdlR6rtNipJ2UEMQLZBn9uSvW +GYdirEObsFYnkKC178MFIB6k5Ub1KFwCr8sxL7qlS0sdySX+1BWKoN7jC5dXLMLx +nK1JtaMZucuE39kk5AMdp8pYrzUokjwdRBCR/EEeZ0M3povSRydXqVEyWc6z9FuH +odsbEXj0dfk/oiZ/RkWcaPKk38GUcSOhFZqtbuQ6JOQb7lCHAgMBAAGjYzBhMA4G +A1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBT2ajkfqkej +VF4PBqHk7IVAsGxFRjAfBgNVHSMEGDAWgBT2ajkfqkejVF4PBqHk7IVAsGxFRjAN +BgkqhkiG9w0BAQsFAAOCAgEAohpkNBs3s0I6CgXQWS0Xrcf8DDLCHwCm+IjA5Uld +Pgu/7DLrnPkYOTqYALh2Q6ZgO7g19Cow92x0eRgnc1ug9rcwFaURD6HNresY1owa +sSRmA1T7miH04ZRf5G9I50BkrdQKoeD5oGulo1JwvX7RS2LEW37eI8IEuThNadz1 +4kOSXVUvrkwY5lz1AUnBMKXkT5m8wfXgJ6WL2AO1HD8pITh3FoeJ88gvgZ68Levc +o1bmg68/6zHNM2l/dxMQGnSlHeZX5Q62OCOwFccS8ZRdegFTECoLOCiWxl/cU515 +3FS2LYhtch0zGLJF9XzPnejjI8k0BtQZjjxF8nYyaY3+snoWcpeERoh/fNuiITH2 +PeK+yQcBjR2IBfBtysuXvxHrMuKGQMuztaTFoAbCW7I69WQS6F7XhxxG/5gLtVGJ +3euQiq22PnjXlRZfWBJIHmQlPOtG57++90fNUiQFg0ST5GOU9nBSfC8DYOXCyPRb +OdVXWCAFMNiKjFRtOZXPikXwx8bF/NTTvD+mZavAV+mg+XpBCoJINyt/KJZ2zLfT +rCbUbGg7y3uWMsf9XEYfnP9r8yVTxqVT204WAxQxDtbatVYvSxUA6VcrOqWmXE35 +DDlPGVHYKgtYEtk3K4zSIubyy78vrnzl4rVpZU9g6DE6tu+oXVbm+qsmgi2sab1t +YyE= +-----END CERTIFICATE----- diff --git a/test/regression/interoperability_test/mqtt_test/test_scripts/CA/certs/broker.server.crt b/test/regression/interoperability_test/mqtt_test/test_scripts/CA/certs/broker.server.crt new file mode 100644 index 00000000..008368e4 --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/test_scripts/CA/certs/broker.server.crt @@ -0,0 +1,32 @@ +-----BEGIN CERTIFICATE----- +MIIFdjCCA16gAwIBAgIBBTANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx +EzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDVNhbiBGcmFuY2lzY28xEzAR +BgNVBAoMCkJvZ3VzIEluYy4xEzARBgNVBAsMCk9wZXJhdGlvbnMxKTAnBgNVBAMM +IEJvZ3VzIEluYy4gQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4XDTIxMDMxNzAyNDkz +N1oXDTMxMDMxNTAyNDkzN1owdTELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlm +b3JuaWExFjAUBgNVBAcMDVNhbiBGcmFuY2lzY28xEzARBgNVBAoMCkJvZ3VzIElu +Yy4xEzARBgNVBAsMCk9wZXJhdGlvbnMxDzANBgNVBAMMBmJyb2tlcjCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBALPo3ShpTYylcdv5smEaG23qhFMtMc7I ++0vxszBZWT8Sw8+FVgyanR+7l1H9kXxwK503EFbxbU6ixLCDtb2EFJ0GdcOT+y3T +gjHqFdCzYxayPb9QfwUxuPNMWsvKBa1mIO3O9NkQtQ6MnXwL6HXNFcJcTqRbjQjw +RIPV+YDGf5omf+OwLrYi+Gtttly9qjWNCqlubPCCY1i1L5fesmUrdVC+5NbtnFAm +De8CtKsD71Vqpj5N0DCAIKVfjNyLzq5fvhs9Pq6IyXxAro5NsL2zqJTLkEHrtAG6 +eaJrSQKElDHqjGxywivoBLEgdS7ohpVjfUGncan81xTv2XwEHRxP0KkCAwEAAaOB +9TCB8jAOBgNVHQ8BAf8EBAMCBaAwCQYDVR0TBAIwADAdBgNVHSUEFjAUBggrBgEF +BQcDAQYIKwYBBQUHAwIwHQYDVR0OBBYEFJRYz75LzLnlr2tgRrTv5++8DzonMB8G +A1UdIwQYMBaAFPZqOR+qR6NUXg8GoeTshUCwbEVGMDYGCCsGAQUFBwEBBCowKDAm +BggrBgEFBQcwAoYaaHR0cDovL2JvZ3VzLmNvbS9jYS9DQS5jcnQwKwYDVR0fBCQw +IjAgoB6gHIYaaHR0cDovL2JvZ3VzLmNvbS9jYS9DQS5jcmwwEQYDVR0RBAowCIIG +YnJva2VyMA0GCSqGSIb3DQEBCwUAA4ICAQBlssMWc/p3kCC5oJzBD++0CDvgtHSv +JLwV7KAz4LbKz7/aVID2z/iy2dOD2y8PsKnCst1u/PHgkTQZR4uwRG1pv5J5VaEN +m9ealZLaltM7R2EKcc/M+Wr1XDcBe3lPmtfjbsiqbSlroVnYfr1G2/WK4OUOjj0A +iwCkT3JKbGIaBz0iriOtyJwa/ChSfEOEwsAl+TESvmG2ilPsCQTC8uqDKokqjx4F +cSiYOYuZxynrcRiyzRwWdpxiRTsTPkqYfdddLbttckkYfLitsWf/EUBSN+Axotr5 +ISXcVCkT6pfruvQhBOEOwpGuySoxN8oy4CxlJ4uQOEYNHApdrX77hWQpKP0yFLs0 +iwH2uuVG2STD2D3ZhHfZAOriL6DrAYzyWhW5sr7Eu3ovrG2k3I7aaYzAGWznbEFf +C1ro+6EJFyqlx+aVLXCxi172EgUw8TM2/fMIR+hS4+JcV4r2qDskPhxyYiyyxwOO +AGGyOIfUKIFsTxQO9DrEaZSa35ylvAe3isircmcNfScB/W/diAWVKd4pJ6bwKbxK +kjsebaWMHz2wvQZJzh8wWh1JFHiR9a7v3MqqXE9Q508pF4olSLKP125cFtTFORSw +aZAQNH5eQNDFI40jlwlhE8xujyGG7dyqzHJdnGljNQKJY3Zij5Wyly5bKdLTwgT/ +A5p/Y/+yy5qA2Q== +-----END CERTIFICATE----- diff --git a/test/regression/interoperability_test/mqtt_test/test_scripts/CA/certs/ew2017.client.crt b/test/regression/interoperability_test/mqtt_test/test_scripts/CA/certs/ew2017.client.crt new file mode 100644 index 00000000..930f2c90 --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/test_scripts/CA/certs/ew2017.client.crt @@ -0,0 +1,31 @@ +-----BEGIN CERTIFICATE----- +MIIFWTCCA0GgAwIBAgIBAzANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx +EzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDVNhbiBGcmFuY2lzY28xEzAR +BgNVBAoMCkJvZ3VzIEluYy4xEzARBgNVBAsMCk9wZXJhdGlvbnMxKTAnBgNVBAMM +IEJvZ3VzIEluYy4gQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4XDTE3MDMwODA0NDEx +NVoXDTE5MDMwODA0NDExNVowdTELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlm +b3JuaWExFjAUBgNVBAcMDVNhbiBGcmFuY2lzY28xEzARBgNVBAoMCkJvZ3VzIElu +Yy4xEzARBgNVBAsMCk9wZXJhdGlvbnMxDzANBgNVBAMMBmV3MjAxNzCCASIwDQYJ +KoZIhvcNAQEBBQADggEPADCCAQoCggEBAL8gZnwnLXpTS8FFi8jF7b6az6TwDyjI +6UwrmZ26SAatFw1NZ3NOzeJIwlpXgeXLhxpXD4zh+SxnOVBR6Yf/o3jYYlc5CPLM +KePPx73H4d+rUOHcs0etLQJnuNN86CLne84x/kifOwScYyT5cX+LiejTqm66rrrN +1bHE/G13pze9SvOtFcOGECkJEfO+VDC2t2WvXLRr+9o9zOkSChBjoVz+rT9pL063 +WSyNFc+hbDxxf6OtXk1GZZCE9f3vRT5F7puEi/78mowK9fS8Z+5qi7/2hhegB8dY +qtuabwmwf5x67yTIP6EgSQgLQZCTSAb/s3Q68Uyaf4x0bh0cslcCzrcCAwEAAaOB +2DCB1TAOBgNVHQ8BAf8EBAMCB4AwCQYDVR0TBAIwADATBgNVHSUEDDAKBggrBgEF +BQcDAjAdBgNVHQ4EFgQUytHvFFpMMpyXcUuE304TXPTAPv0wHwYDVR0jBBgwFoAU +9mo5H6pHo1ReDwah5OyFQLBsRUYwNgYIKwYBBQUHAQEEKjAoMCYGCCsGAQUFBzAC +hhpodHRwOi8vYm9ndXMuY29tL2NhL0NBLmNydDArBgNVHR8EJDAiMCCgHqAchhpo +dHRwOi8vYm9ndXMuY29tL2NhL0NBLmNybDANBgkqhkiG9w0BAQsFAAOCAgEAF2JJ +il9rEIVOlPgPuBnqwLXBsK/bI2gKZiw4XHyKWB98YEqxxXN7lOyidldY4tisMTRl +KiQLTYKlmfztEAlE/4AnSFqbs8ArnhNF34o7Emc43p1RYfpEOo9+GpkwHzUwiM+D +jdr9Nu0dWEkB4AZIk3n8rxv/CZbPXpbzQtm9O/R3Ee2bgtrrlA8Fjodq5fVNx324 +dyiBLzyRX7YLkFB/yX4OwDsl4rYZUNpKroc1fLkiOu4paSJm3Ai1FhGOOLus2n1v +do8EwOhMKf3gcwTI9TYaAFpwYStX/1+YMR4RfwBp960tDXHSqiXm+WvVPTb9yY7g +owzbfMi4ALFVLU7dVc0FNaOrV7SIVCOI2IE2CP8nsREUFzfZ9QNi6hPmiEX7Ol0h +K76w7dqHh0S8lXiqPr71BmkPXT6mKt4gNFqPNnuMKT7HbRseOu/oKYYk6vXk/Zs7 +XFmwotwyBqsqIm988AijrIfpDw39NG+esa7evBPVaxhWSAomyPjEfO83QZuE2UM+ +YYyDKiyG/bHVQNycDC7lBXWbaUUobOdpCEzsRy5VOUzpLY32jJNN54F3VSsI9hd3 +1d/o0ei/yLfN9XkocyYEalkpX8hELqL0tuNAwHJVnT77gSYUmFsFjobEnlZrXSEP +IjeLvaH6jjbAK/vhMW1VFeJRWR2hlAC9HIH8k7U= +-----END CERTIFICATE----- diff --git a/test/regression/interoperability_test/mqtt_test/test_scripts/CA/private/broker.server.key b/test/regression/interoperability_test/mqtt_test/test_scripts/CA/private/broker.server.key new file mode 100644 index 00000000..2158ee86 --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/test_scripts/CA/private/broker.server.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCz6N0oaU2MpXHb ++bJhGhtt6oRTLTHOyPtL8bMwWVk/EsPPhVYMmp0fu5dR/ZF8cCudNxBW8W1OosSw +g7W9hBSdBnXDk/st04Ix6hXQs2MWsj2/UH8FMbjzTFrLygWtZiDtzvTZELUOjJ18 +C+h1zRXCXE6kW40I8ESD1fmAxn+aJn/jsC62IvhrbbZcvao1jQqpbmzwgmNYtS+X +3rJlK3VQvuTW7ZxQJg3vArSrA+9VaqY+TdAwgCClX4zci86uX74bPT6uiMl8QK6O +TbC9s6iUy5BB67QBunmia0kChJQx6oxscsIr6ASxIHUu6IaVY31Bp3Gp/NcU79l8 +BB0cT9CpAgMBAAECggEBAJu9wP3DssNHUXpo/Lc8X3RWaLiMTirBJ3GFyWXYYv7L +4sBZn7UHf29B+Gucw33iqI7PZRCurL4+/2AClKh7l1CbkAR/rRftmi5Vgw8Iy4WR +RQzBxUOc2IudlJgHycRivay/1Iu3/9SZe5cvw8t+fxCi0d1L95o+TEGIURXeQAYT +TF5SAhh2thy6EFTN4aCujoQXZJD6Suco8yM3Lh05gooYOm7QqAWDxWFH/ZMeuV6H +6yV9GR8EfXih7RvtB+nl9Ky1bxnzK5y2CZS1VEDCf0oK3Kb4nU8KWZBzhWOI/Alx +Ckk87CCCv37y2Qam09aySlMSoWg1kS9WTLyZHJnAeIUCgYEA2Ax5hc/6auYepczy +i+wTKjg6YAGoG6cOp4oPD8DHUegsiuVk9P5k6+/M8/XucJPMEKIBU5I5mQh9eiju +e5tPRaiO12RSDrbDj/rTrHh+bjOm7+gCzvBWUp51446K54hLltM3TlFrIlE8ZrPg +QzF2uGOBhR8eL6UJeJy+1RauKH8CgYEA1S2Z3eK4ii8iqtJuWw1wMBLQZ890zVEK +nB/LwflkbHTYq26dvHDi29MsELvQqCSAjAwIaRaV/9JZK0f4sQyfC4xOdmHMdyGy +LKyB0sBR5Ra87djp32peGT134Y5s0qsWTJK5dpTc036BdP2A4rS+ybU4oCYar012 +wE37cKpdMtcCgYEAmmtAKI5glCtqWGNGMRBJGnIZ9yj3+NvMs58P6NiHHlnuDFCt +ehaiF6jMOsra5AgfYPwKKqtnE6Rn2vqKijqVzFoPzo/bvryOxsgmpy1wYF/2v556 +82IAsQilhkIJsjdOn7zT2NyE0IBzxYxnjF88Vcp5dqapMrCpNlYCZ9fQHw0CgYEA +0QmOP836N0ZRMEB4hkB/KiTIx4LefhZh2QY0v1jV6KQLcs9dTVNEoVpJc3839CkX +BD0oYiQLoneZiJ9idfpyWtiSd/MelBMurC/cfdSoeYP6byCs9K9Q5l8oFr2aaFnr +29pkkqsWfy0ltJqAr82c6B4UELZMpGnJcHkHfksQaLECgYBoscsWND7nu4XIW52m +m1XwhiHgHmr7VzD1LrrptStJCi75yM3qFlk1sijxUpiZSUsbSi9pJHmptdZWNxEq +MVIn1jy/IWaNRsAjazo78Z5yqTDeCkyyt3afXrmdvKwM5jSX4ffWW3L0p8AX8Zuh +zEz+htzHAfK8SxrgbCeYiLGOgQ== +-----END PRIVATE KEY----- diff --git a/test/regression/interoperability_test/mqtt_test/test_scripts/CA/private/ew2017.client.key b/test/regression/interoperability_test/mqtt_test/test_scripts/CA/private/ew2017.client.key new file mode 100644 index 00000000..457211e6 --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/test_scripts/CA/private/ew2017.client.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC/IGZ8Jy16U0vB +RYvIxe2+ms+k8A8oyOlMK5mdukgGrRcNTWdzTs3iSMJaV4Hly4caVw+M4fksZzlQ +UemH/6N42GJXOQjyzCnjz8e9x+Hfq1Dh3LNHrS0CZ7jTfOgi53vOMf5InzsEnGMk ++XF/i4no06puuq66zdWxxPxtd6c3vUrzrRXDhhApCRHzvlQwtrdlr1y0a/vaPczp +EgoQY6Fc/q0/aS9Ot1ksjRXPoWw8cX+jrV5NRmWQhPX970U+Re6bhIv+/JqMCvX0 +vGfuaou/9oYXoAfHWKrbmm8JsH+ceu8kyD+hIEkIC0GQk0gG/7N0OvFMmn+MdG4d +HLJXAs63AgMBAAECggEAV5I04vXgdIft0eRXo+psgETWlzAXAgzsOCZSAF712Xk9 +cq7gk4ir9N55joNB1VRn1r3FNjvju2CgdhjR86pB8IDUrjpHy1eYafUuA9qtt5n7 +OUGyM0k5sjxsBxrYEgYWR+fIJuYuWHJ/StWwF0yMJ82z7YBDxvvAye8D6fRE/dhG +jDjQ5W6KBZFBRFxAt9Qed1Hu3vdXoBQzoWkf6lvTJfYVkTG9D3HTYhb0HHMvVfPA +3mVqW5GwFydC8yYukalCa4sbkJQAdXILEPzTz3UnuYCAJJ6Gmt0CXXUVKEDvrPcZ +RyDKdtksCwYQu5y2vOr9AsnqW7s33vcQVHjs7sJHYQKBgQDqu2Okn0Ob1FrZh6Cj +j3vw1LegequkkoTh01vALiSnQO4Ls0hmhrao+bsKVWXibfIHBfWOmaAzCdjIsDwA +1ZJjNTpdmgWSmZIEPS2ZPsw0BV/QTCJw/I8nRp6D20wOBK4P5JDVv8M23KxShdwM +A5xfsBNEkgU5JpAU82YIgFJRNQKBgQDQcZU0uoy7bneq/VdhaUvF0iHdtKJgsnYm +aF4f+ji5O7wY8WGgSu2IgU1fB/+fsKq4z5bLbkCT6ay9H4RlqMePuT7mtzizoso8 +4o+NAQtwvJlJrv45/XcdQaUKM8M2YGVSHq1SscLOIp90tJjdMnerW5viA/TDOZps +F94kGGApuwKBgQCorNufkmrM8b4PDu0aW6Menl0NztjEvB0NAgqugPoJzhjBA6YF +NszPhBUqCc/a9FK1RUz9mduKkYrcO/gCSXaWH8u/M0zJ2d0ZerTnqD6pKyt8zRj6 +xCJCgParncx7TlWeSgrh7pjjNZQHAPXtFDMsd6SA48UpGlLzGyy48y0z+QKBgQCH +UDS79h5FzoCAz9VZtzEpSjAR7KE8hJ2OcVIpEBaiqNSCnK/zjrCEXOwNNPQMhnNN +ZfVOOlRRsPAiFcOs+tQRyP+8ZlS4yITg4XKu5m620LfxzVfb7V7V7zdkWBXxxsH/ +fUqm1B7SEkfRSyuw7IIjC2U2Y7sQwOQuJ5BdfjVu4QKBgQDql+jpSV65MhpqKY7Q +8qxI0Eu7s05AZgJD+QARGj8HhVpkf74UiTwahu/OR56p9HgLmI7/3uQSXNrx78co +00shiCONSe15p7CIR4/LrxcE7UUHyyaQM4x2R3ZaG65ciw6c4Uy35m3fXJFXLNx9 +GyLdLswBKAxbXUJpn2nSd0an+w== +-----END PRIVATE KEY----- diff --git a/test/regression/interoperability_test/mqtt_test/test_scripts/bridge_server.sh b/test/regression/interoperability_test/mqtt_test/test_scripts/bridge_server.sh new file mode 100644 index 00000000..4f64f1ba --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/test_scripts/bridge_server.sh @@ -0,0 +1,5 @@ +#! /bin/sh +if [ -d "../mosquitto-1.6.9/src/" ]; then + export PATH=$PATH;../mosquitto-1.4.10/src/ +fi +mosquitto -c ./mosquitto-bridge.conf -v -p 8883 diff --git a/test/regression/interoperability_test/mqtt_test/test_scripts/certificate_server.sh b/test/regression/interoperability_test/mqtt_test/test_scripts/certificate_server.sh new file mode 100755 index 00000000..b7711aaf --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/test_scripts/certificate_server.sh @@ -0,0 +1,14 @@ +#! /bin/bash + +function kill_mqtt_server(){ + kill $mqtt_server_pid + wait +} + +dir=`dirname $0` +dir=`realpath $dir` +cd $dir +mosquitto -c ./mosquitto.conf -v $* & +mqtt_server_pid=$! +trap kill_mqtt_server TERM ALRM +wait diff --git a/test/regression/interoperability_test/mqtt_test/test_scripts/mosquitto-bridge.conf b/test/regression/interoperability_test/mqtt_test/test_scripts/mosquitto-bridge.conf new file mode 100644 index 00000000..b9b618e5 --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/test_scripts/mosquitto-bridge.conf @@ -0,0 +1,511 @@ +# Config file for mosquitto +# +# See mosquitto.conf(5) for more information. +# +# Default values are shown, uncomment to change. +# +# Use the # character to indicate a comment, but only if it is the +# very first character on the line. + +# ================================================================= +# General configuration +# ================================================================= + +# Time in seconds to wait before resending an outgoing QoS=1 or +# QoS=2 message. +#retry_interval 20 + +# Time in seconds between updates of the $SYS tree. +# Set to 0 to disable the publishing of the $SYS tree. +#sys_interval 10 + +# Time in seconds between cleaning the internal message store of +# unreferenced messages. Lower values will result in lower memory +# usage but more processor time, higher values will have the +# opposite effect. +# Setting a value of 0 means the unreferenced messages will be +# disposed of as quickly as possible. +#store_clean_interval 10 + +# Write process id to a file. Default is a blank string which means +# a pid file shouldn't be written. +# This should be set to /var/run/mosquitto.pid if mosquitto is +# being run automatically on boot with an init script and +# start-stop-daemon or similar. +#pid_file + +# When run as root, drop privileges to this user and its primary +# group. +# Leave blank to stay as root, but this is not recommended. +# If run as a non-root user, this setting has no effect. +# Note that on Windows this has no effect and so mosquitto should +# be started by the user you wish it to run as. +#user mosquitto + +# The maximum number of QoS 1 and 2 messages currently inflight per +# client. +# This includes messages that are partway through handshakes and +# those that are being retried. Defaults to 20. Set to 0 for no +# maximum. Setting to 1 will guarantee in-order delivery of QoS 1 +# and 2 messages. +#max_inflight_messages 20 + +# The maximum number of QoS 1 and 2 messages to hold in a queue +# above those that are currently in-flight. Defaults to 100. Set +# to 0 for no maximum (not recommended). +# See also queue_qos0_messages. +#max_queued_messages 100 + +# Set to true to queue messages with QoS 0 when a persistent client is +# disconnected. These messages are included in the limit imposed by +# max_queued_messages. +# Defaults to false. +# This is a non-standard option for the MQTT v3.1 spec but is allowed in +# v3.1.1. +#queue_qos0_messages false + +# This option sets the maximum publish payload size that the broker will allow. +# Received messages that exceed this size will not be accepted by the broker. +# The default value is 0, which means that all valid MQTT messages are +# accepted. MQTT imposes a maximum payload size of 268435455 bytes. +#message_size_limit 0 + +# This option controls whether a client is allowed to connect with a zero +# length client id or not. This option only affects clients using MQTT v3.1.1 +# and later. If set to false, clients connecting with a zero length client id +# are disconnected. If set to true, clients will be allocated a client id by +# the broker. This means it is only useful for clients with clean session set +# to true. +#allow_zero_length_clientid true + +# If allow_zero_length_clientid is true, this option allows you to set a prefix +# to automatically generated client ids to aid visibility in logs. +#auto_id_prefix + +# This option allows persistent clients (those with clean session set to false) +# to be removed if they do not reconnect within a certain time frame. +# +# This is a non-standard option in MQTT V3.1 but allowed in MQTT v3.1.1. +# +# Badly designed clients may set clean session to false whilst using a randomly +# generated client id. This leads to persistent clients that will never +# reconnect. This option allows these clients to be removed. +# +# The expiration period should be an integer followed by one of h d w m y for +# hour, day, week, month and year respectively. For example +# +# persistent_client_expiration 2m +# persistent_client_expiration 14d +# persistent_client_expiration 1y +# +# The default if not set is to never expire persistent clients. +#persistent_client_expiration + +# If a client is subscribed to multiple subscriptions that overlap, e.g. foo/# +# and foo/+/baz , then MQTT expects that when the broker receives a message on +# a topic that matches both subscriptions, such as foo/bar/baz, then the client +# should only receive the message once. +# Mosquitto keeps track of which clients a message has been sent to in order to +# meet this requirement. The allow_duplicate_messages option allows this +# behaviour to be disabled, which may be useful if you have a large number of +# clients subscribed to the same set of topics and are very concerned about +# minimising memory usage. +# It can be safely set to true if you know in advance that your clients will +# never have overlapping subscriptions, otherwise your clients must be able to +# correctly deal with duplicate messages even when then have QoS=2. +#allow_duplicate_messages false + +# The MQTT specification requires that the QoS of a message delivered to a +# subscriber is never upgraded to match the QoS of the subscription. Enabling +# this option changes this behaviour. If upgrade_outgoing_qos is set true, +# messages sent to a subscriber will always match the QoS of its subscription. +# This is a non-standard option explicitly disallowed by the spec. +#upgrade_outgoing_qos false + +# ================================================================= +# Default listener +# ================================================================= + +# IP address/hostname to bind the default listener to. If not +# given, the default listener will not be bound to a specific +# address and so will be accessible to all network interfaces. +# bind_address ip-address/host name +#bind_address + +# Port to use for the default listener. +#port 1883 +listener 8884 + +# The maximum number of client connections to allow. This is +# a per listener setting. +# Default is -1, which means unlimited connections. +# Note that other process limits mean that unlimited connections +# are not really possible. Typically the default maximum number of +# connections possible is around 1024. +#max_connections -1 + +# Choose the protocol to use when listening. +# This can be either mqtt or websockets. +# Websockets support is currently disabled by default at compile time. +# Certificate based TLS may be used with websockets, except that +# only the cafile, certfile, keyfile and ciphers options are supported. +#protocol mqtt + +# When a listener is using the websockets protocol, it is possible to serve +# http data as well. Set http_dir to a directory which contains the files you +# wish to serve. If this option is not specified, then no normal http +# connections will be possible. +#http_dir + +# Set use_username_as_clientid to true to replace the clientid that a client +# connected with with its username. This allows authentication to be tied to +# the clientid, which means that it is possible to prevent one client +# disconnecting another by using the same clientid. +# If a client connects with no username it will be disconnected as not +# authorised when this option is set to true. +# Do not use in conjunction with clientid_prefixes. +# See also use_identity_as_username. +#use_username_as_clientid + +# ----------------------------------------------------------------- +# Certificate based SSL/TLS support +# ----------------------------------------------------------------- +# The following options can be used to enable SSL/TLS support for +# this listener. Note that the recommended port for MQTT over TLS +# is 8883, but this must be set manually. +# +# See also the mosquitto-tls man page. + +# At least one of cafile or capath must be defined. They both +# define methods of accessing the PEM encoded Certificate +# Authority certificates that have signed your server certificate +# and that you wish to trust. +# cafile defines the path to a file containing the CA certificates. +# capath defines a directory that will be searched for files +# containing the CA certificates. For capath to work correctly, the +# certificate files must have ".crt" as the file ending and you must run +# "c_rehash <path to capath>" each time you add/remove a certificate. +cafile CA/ca/ca.crt +#capath + +# Path to the PEM encoded server certificate. +#certfile ./cert.pem +certfile CA/certs/broker.server.crt + + +# Path to the PEM encoded keyfile. +#keyfile ./keyout.pem +keyfile CA/private/broker.server.key + +# This option defines the version of the TLS protocol to use for this listener. +# The default value allows v1.2, v1.1 and v1.0, if they are all supported by +# the version of openssl that the broker was compiled against. For openssl >= +# 1.0.1 the valid values are tlsv1.2 tlsv1.1 and tlsv1. For openssl < 1.0.1 the +# valid values are tlsv1. +#tls_version tlsv1.2 + +# By default a TLS enabled listener will operate in a similar fashion to a +# https enabled web server, in that the server has a certificate signed by a CA +# and the client will verify that it is a trusted certificate. The overall aim +# is encryption of the network traffic. By setting require_certificate to true, +# the client must provide a valid certificate in order for the network +# connection to proceed. This allows access to the broker to be controlled +# outside of the mechanisms provided by MQTT. +#require_certificate true + +# If require_certificate is true, you may set use_identity_as_username to true +# to use the CN value from the client certificate as a username. If this is +# true, the password_file option will not be used for this listener. +#use_identity_as_username false + +# If you have require_certificate set to true, you can create a certificate +# revocation list file to revoke access to particular client certificates. If +# you have done this, use crlfile to point to the PEM encoded revocation file. +#crlfile + +# If you wish to control which encryption ciphers are used, use the ciphers +# option. The list of available ciphers can be optained using the "openssl +# ciphers" command and should be provided in the same format as the output of +# that command. +# If unset defaults to DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:@STRENGTH +#ciphers DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:@STRENGTH + +# ----------------------------------------------------------------- +# Pre-shared-key based SSL/TLS support +# ----------------------------------------------------------------- +# The following options can be used to enable PSK based SSL/TLS support for +# this listener. Note that the recommended port for MQTT over TLS is 8883, but +# this must be set manually. +# +# See also the mosquitto-tls man page and the "Certificate based SSL/TLS +# support" section. Only one of certificate or PSK encryption support can be +# enabled for any listener. + +# The psk_hint option enables pre-shared-key support for this listener and also +# acts as an identifier for this listener. The hint is sent to clients and may +# be used locally to aid authentication. The hint is a free form string that +# doesn't have much meaning in itself, so feel free to be creative. +# If this option is provided, see psk_file to define the pre-shared keys to be +# used or create a security plugin to handle them. +#psk_hint Client_identity + +# Set use_identity_as_username to have the psk identity sent by the client used +# as its username. Authentication will be carried out using the PSK rather than +# the MQTT username/password and so password_file will not be used for this +# listener. +#use_identity_as_username true + +# When using PSK, the encryption ciphers used will be chosen from the list of +# available PSK ciphers. If you want to control which ciphers are available, +# use the "ciphers" option. The list of available ciphers can be optained +# using the "openssl ciphers" command and should be provided in the same format +# as the output of that command. +#ciphers + +# ================================================================= +# Persistence +# ================================================================= + +# If persistence is enabled, save the in-memory database to disk +# every autosave_interval seconds. If set to 0, the persistence +# database will only be written when mosquitto exits. See also +# autosave_on_changes. +# Note that writing of the persistence database can be forced by +# sending mosquitto a SIGUSR1 signal. +#autosave_interval 1800 + +# If true, mosquitto will count the number of subscription changes, retained +# messages received and queued messages and if the total exceeds +# autosave_interval then the in-memory database will be saved to disk. +# If false, mosquitto will save the in-memory database to disk by treating +# autosave_interval as a time in seconds. +#autosave_on_changes false + +# Save persistent message data to disk (true/false). +# This saves information about all messages, including +# subscriptions, currently in-flight messages and retained +# messages. +# retained_persistence is a synonym for this option. +#persistence false + +# The filename to use for the persistent database, not including +# the path. +#persistence_file mosquitto.db + +# Location for persistent database. Must include trailing / +# Default is an empty string (current directory). +# Set to e.g. /var/lib/mosquitto/ if running as a proper service on Linux or +# similar. +#persistence_location + +# ================================================================= +# Logging +# ================================================================= + +# Places to log to. Use multiple log_dest lines for multiple +# logging destinations. +# Possible destinations are: stdout stderr syslog topic file +# +# stdout and stderr log to the console on the named output. +# +# syslog uses the userspace syslog facility which usually ends up +# in /var/log/messages or similar. +# +# topic logs to the broker topic '$SYS/broker/log/<severity>', +# where severity is one of D, E, W, N, I, M which are debug, error, +# warning, notice, information and message. Message type severity is used by +# the subscribe/unsubscribe log_types and publishes log messages to +# $SYS/broker/log/M/susbcribe or $SYS/broker/log/M/unsubscribe. +# +# The file destination requires an additional parameter which is the file to be +# logged to, e.g. "log_dest file /var/log/mosquitto.log". The file will be +# closed and reopened when the broker receives a HUP signal. Only a single file +# destination may be configured. +# +# Note that if the broker is running as a Windows service it will default to +# "log_dest none" and neither stdout nor stderr logging is available. +# Use "log_dest none" if you wish to disable logging. +#log_dest stderr + +# If using syslog logging (not on Windows), messages will be logged to the +# "daemon" facility by default. Use the log_facility option to choose which of +# local0 to local7 to log to instead. The option value should be an integer +# value, e.g. "log_facility 5" to use local5. +#log_facility + +# Types of messages to log. Use multiple log_type lines for logging +# multiple types of messages. +# Possible types are: debug, error, warning, notice, information, +# none, subscribe, unsubscribe, websockets, all. +# Note that debug type messages are for decoding the incoming/outgoing +# network packets. They are not logged in "topics". +#log_type error +#log_type warning +#log_type notice +#log_type information + +# Change the websockets logging level. This is a global option, it is not +# possible to set per listener. This is an integer that is interpreted by +# libwebsockets as a bit mask for its lws_log_levels enum. See the +# libwebsockets documentation for more details. "log_type websockets" must also +# be enabled. +#websockets_log_level 0 + +# If set to true, client connection and disconnection messages will be included +# in the log. +#connection_messages true + +# If set to true, add a timestamp value to each log message. +#log_timestamp true + +# ================================================================= +# Security +# ================================================================= + +# If set, only clients that have a matching prefix on their +# clientid will be allowed to connect to the broker. By default, +# all clients may connect. +# For example, setting "secure-" here would mean a client "secure- +# client" could connect but another with clientid "mqtt" couldn't. +#clientid_prefixes + +# Boolean value that determines whether clients that connect +# without providing a username are allowed to connect. If set to +# false then a password file should be created (see the +# password_file option) to control authenticated client access. +# Defaults to true. +allow_anonymous true + +# In addition to the clientid_prefixes, allow_anonymous and TLS +# authentication options, username based authentication is also +# possible. The default support is described in "Default +# authentication and topic access control" below. The auth_plugin +# allows another authentication method to be used. +# Specify the path to the loadable plugin and see the +# "Authentication and topic access plugin options" section below. +#auth_plugin + +# ----------------------------------------------------------------- +# Default authentication and topic access control +# ----------------------------------------------------------------- + +# Control access to the broker using a password file. This file can be +# generated using the mosquitto_passwd utility. If TLS support is not compiled +# into mosquitto (it is recommended that TLS support should be included) then +# plain text passwords are used, in which case the file should be a text file +# with lines in the format: +# username:password +# The password (and colon) may be omitted if desired, although this +# offers very little in the way of security. +# +# See the TLS client require_certificate and use_identity_as_username options +# for alternative authentication options. +#password_file + +# Access may also be controlled using a pre-shared-key file. This requires +# TLS-PSK support and a listener configured to use it. The file should be text +# lines in the format: +# identity:key +# The key should be in hexadecimal format without a leading "0x". +#psk_file ./psk_file.txt + +# Control access to topics on the broker using an access control list +# file. If this parameter is defined then only the topics listed will +# have access. +# If the first character of a line of the ACL file is a # it is treated as a +# comment. +# Topic access is added with lines of the format: +# +# topic [read|write|readwrite] <topic> +# +# The access type is controlled using "read", "write" or "readwrite". This +# parameter is optional (unless <topic> contains a space character) - if not +# given then the access is read/write. <topic> can contain the + or # +# wildcards as in subscriptions. +# +# The first set of topics are applied to anonymous clients, assuming +# allow_anonymous is true. User specific topic ACLs are added after a +# user line as follows: +# +# user <username> +# +# The username referred to here is the same as in password_file. It is +# not the clientid. +# +# +# If is also possible to define ACLs based on pattern substitution within the +# topic. The patterns available for substition are: +# +# %c to match the client id of the client +# %u to match the username of the client +# +# The substitution pattern must be the only text for that level of hierarchy. +# +# The form is the same as for the topic keyword, but using pattern as the +# keyword. +# Pattern ACLs apply to all users even if the "user" keyword has previously +# been given. +# +# If using bridges with usernames and ACLs, connection messages can be allowed +# with the following pattern: +# pattern write $SYS/broker/connection/%c/state +# +# pattern [read|write|readwrite] <topic> +# +# Example: +# +# pattern write sensor/%u/data +# +#acl_file + +# ----------------------------------------------------------------- +# Authentication and topic access plugin options +# ----------------------------------------------------------------- + +# If the auth_plugin option above is used, define options to pass to the +# plugin here as described by the plugin instructions. All options named +# using the format auth_opt_* will be passed to the plugin, for example: +# +# auth_opt_db_host +# auth_opt_db_port +# auth_opt_db_username +# auth_opt_db_password + +# ================================================================= +# External config files +# ================================================================= + +# External configuration files may be included by using the +# include_dir option. This defines a directory that will be searched +# for config files. All files that end in '.conf' will be loaded as +# a configuration file. It is best to have this as the last option +# in the main file. This option will only be processed from the main +# configuration file. The directory specified must not contain the +# main configuration file. +#include_dir + +# ================================================================= +# rsmb options - unlikely to ever be supported +# ================================================================= + +#ffdc_output +#max_log_entries +#trace_level +#trace_output + + + +# Bridge +connection awsiot +address a1m35stuxxwf0e.iot.us-west-2.amazonaws.com:8883 +topic # both 0 +bridge_protocol_version mqttv311 +bridge_insecure false +cleansession true +clientid bridgeawsiot +start_type automatic +notifications false +log_type all +bridge_cafile aws_keys/ca.pem +bridge_certfile aws_keys/643ad617ec-certificate.pem.crt +bridge_keyfile aws_keys/643ad617ec-private.pem.key diff --git a/test/regression/interoperability_test/mqtt_test/test_scripts/mosquitto-psk.conf b/test/regression/interoperability_test/mqtt_test/test_scripts/mosquitto-psk.conf new file mode 100644 index 00000000..204a0e03 --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/test_scripts/mosquitto-psk.conf @@ -0,0 +1,492 @@ +# Config file for mosquitto +# +# See mosquitto.conf(5) for more information. +# +# Default values are shown, uncomment to change. +# +# Use the # character to indicate a comment, but only if it is the +# very first character on the line. + +# ================================================================= +# General configuration +# ================================================================= + +# Time in seconds to wait before resending an outgoing QoS=1 or +# QoS=2 message. +#retry_interval 20 + +# Time in seconds between updates of the $SYS tree. +# Set to 0 to disable the publishing of the $SYS tree. +#sys_interval 10 + +# Time in seconds between cleaning the internal message store of +# unreferenced messages. Lower values will result in lower memory +# usage but more processor time, higher values will have the +# opposite effect. +# Setting a value of 0 means the unreferenced messages will be +# disposed of as quickly as possible. +#store_clean_interval 10 + +# Write process id to a file. Default is a blank string which means +# a pid file shouldn't be written. +# This should be set to /var/run/mosquitto.pid if mosquitto is +# being run automatically on boot with an init script and +# start-stop-daemon or similar. +#pid_file + +# When run as root, drop privileges to this user and its primary +# group. +# Leave blank to stay as root, but this is not recommended. +# If run as a non-root user, this setting has no effect. +# Note that on Windows this has no effect and so mosquitto should +# be started by the user you wish it to run as. +#user mosquitto + +# The maximum number of QoS 1 and 2 messages currently inflight per +# client. +# This includes messages that are partway through handshakes and +# those that are being retried. Defaults to 20. Set to 0 for no +# maximum. Setting to 1 will guarantee in-order delivery of QoS 1 +# and 2 messages. +#max_inflight_messages 20 + +# The maximum number of QoS 1 and 2 messages to hold in a queue +# above those that are currently in-flight. Defaults to 100. Set +# to 0 for no maximum (not recommended). +# See also queue_qos0_messages. +#max_queued_messages 100 + +# Set to true to queue messages with QoS 0 when a persistent client is +# disconnected. These messages are included in the limit imposed by +# max_queued_messages. +# Defaults to false. +# This is a non-standard option for the MQTT v3.1 spec but is allowed in +# v3.1.1. +#queue_qos0_messages false + +# This option sets the maximum publish payload size that the broker will allow. +# Received messages that exceed this size will not be accepted by the broker. +# The default value is 0, which means that all valid MQTT messages are +# accepted. MQTT imposes a maximum payload size of 268435455 bytes. +#message_size_limit 0 + +# This option controls whether a client is allowed to connect with a zero +# length client id or not. This option only affects clients using MQTT v3.1.1 +# and later. If set to false, clients connecting with a zero length client id +# are disconnected. If set to true, clients will be allocated a client id by +# the broker. This means it is only useful for clients with clean session set +# to true. +#allow_zero_length_clientid true + +# If allow_zero_length_clientid is true, this option allows you to set a prefix +# to automatically generated client ids to aid visibility in logs. +#auto_id_prefix + +# This option allows persistent clients (those with clean session set to false) +# to be removed if they do not reconnect within a certain time frame. +# +# This is a non-standard option in MQTT V3.1 but allowed in MQTT v3.1.1. +# +# Badly designed clients may set clean session to false whilst using a randomly +# generated client id. This leads to persistent clients that will never +# reconnect. This option allows these clients to be removed. +# +# The expiration period should be an integer followed by one of h d w m y for +# hour, day, week, month and year respectively. For example +# +# persistent_client_expiration 2m +# persistent_client_expiration 14d +# persistent_client_expiration 1y +# +# The default if not set is to never expire persistent clients. +#persistent_client_expiration + +# If a client is subscribed to multiple subscriptions that overlap, e.g. foo/# +# and foo/+/baz , then MQTT expects that when the broker receives a message on +# a topic that matches both subscriptions, such as foo/bar/baz, then the client +# should only receive the message once. +# Mosquitto keeps track of which clients a message has been sent to in order to +# meet this requirement. The allow_duplicate_messages option allows this +# behaviour to be disabled, which may be useful if you have a large number of +# clients subscribed to the same set of topics and are very concerned about +# minimising memory usage. +# It can be safely set to true if you know in advance that your clients will +# never have overlapping subscriptions, otherwise your clients must be able to +# correctly deal with duplicate messages even when then have QoS=2. +#allow_duplicate_messages false + +# The MQTT specification requires that the QoS of a message delivered to a +# subscriber is never upgraded to match the QoS of the subscription. Enabling +# this option changes this behaviour. If upgrade_outgoing_qos is set true, +# messages sent to a subscriber will always match the QoS of its subscription. +# This is a non-standard option explicitly disallowed by the spec. +#upgrade_outgoing_qos false + +# ================================================================= +# Default listener +# ================================================================= + +# IP address/hostname to bind the default listener to. If not +# given, the default listener will not be bound to a specific +# address and so will be accessible to all network interfaces. +# bind_address ip-address/host name +#bind_address + +# Port to use for the default listener. +#port 1883 +listener 8884 + +# The maximum number of client connections to allow. This is +# a per listener setting. +# Default is -1, which means unlimited connections. +# Note that other process limits mean that unlimited connections +# are not really possible. Typically the default maximum number of +# connections possible is around 1024. +#max_connections -1 + +# Choose the protocol to use when listening. +# This can be either mqtt or websockets. +# Websockets support is currently disabled by default at compile time. +# Certificate based TLS may be used with websockets, except that +# only the cafile, certfile, keyfile and ciphers options are supported. +#protocol mqtt + +# When a listener is using the websockets protocol, it is possible to serve +# http data as well. Set http_dir to a directory which contains the files you +# wish to serve. If this option is not specified, then no normal http +# connections will be possible. +#http_dir + +# Set use_username_as_clientid to true to replace the clientid that a client +# connected with with its username. This allows authentication to be tied to +# the clientid, which means that it is possible to prevent one client +# disconnecting another by using the same clientid. +# If a client connects with no username it will be disconnected as not +# authorised when this option is set to true. +# Do not use in conjunction with clientid_prefixes. +# See also use_identity_as_username. +#use_username_as_clientid + +# ----------------------------------------------------------------- +# Certificate based SSL/TLS support +# ----------------------------------------------------------------- +# The following options can be used to enable SSL/TLS support for +# this listener. Note that the recommended port for MQTT over TLS +# is 8883, but this must be set manually. +# +# See also the mosquitto-tls man page. + +# At least one of cafile or capath must be defined. They both +# define methods of accessing the PEM encoded Certificate +# Authority certificates that have signed your server certificate +# and that you wish to trust. +# cafile defines the path to a file containing the CA certificates. +# capath defines a directory that will be searched for files +# containing the CA certificates. For capath to work correctly, the +# certificate files must have ".crt" as the file ending and you must run +# "c_rehash <path to capath>" each time you add/remove a certificate. +#cafile +#capath + +# Path to the PEM encoded server certificate. +#certfile + + +# Path to the PEM encoded keyfile. +#keyfile + +# This option defines the version of the TLS protocol to use for this listener. +# The default value allows v1.2, v1.1 and v1.0, if they are all supported by +# the version of openssl that the broker was compiled against. For openssl >= +# 1.0.1 the valid values are tlsv1.2 tlsv1.1 and tlsv1. For openssl < 1.0.1 the +# valid values are tlsv1. +#tls_version + +# By default a TLS enabled listener will operate in a similar fashion to a +# https enabled web server, in that the server has a certificate signed by a CA +# and the client will verify that it is a trusted certificate. The overall aim +# is encryption of the network traffic. By setting require_certificate to true, +# the client must provide a valid certificate in order for the network +# connection to proceed. This allows access to the broker to be controlled +# outside of the mechanisms provided by MQTT. +#require_certificate false + +# If require_certificate is true, you may set use_identity_as_username to true +# to use the CN value from the client certificate as a username. If this is +# true, the password_file option will not be used for this listener. +#use_identity_as_username false + +# If you have require_certificate set to true, you can create a certificate +# revocation list file to revoke access to particular client certificates. If +# you have done this, use crlfile to point to the PEM encoded revocation file. +#crlfile + +# If you wish to control which encryption ciphers are used, use the ciphers +# option. The list of available ciphers can be optained using the "openssl +# ciphers" command and should be provided in the same format as the output of +# that command. +# If unset defaults to DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:@STRENGTH +#ciphers DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:@STRENGTH + +# ----------------------------------------------------------------- +# Pre-shared-key based SSL/TLS support +# ----------------------------------------------------------------- +# The following options can be used to enable PSK based SSL/TLS support for +# this listener. Note that the recommended port for MQTT over TLS is 8883, but +# this must be set manually. +# +# See also the mosquitto-tls man page and the "Certificate based SSL/TLS +# support" section. Only one of certificate or PSK encryption support can be +# enabled for any listener. + +# The psk_hint option enables pre-shared-key support for this listener and also +# acts as an identifier for this listener. The hint is sent to clients and may +# be used locally to aid authentication. The hint is a free form string that +# doesn't have much meaning in itself, so feel free to be creative. +# If this option is provided, see psk_file to define the pre-shared keys to be +# used or create a security plugin to handle them. +psk_hint Client_identity + +# Set use_identity_as_username to have the psk identity sent by the client used +# as its username. Authentication will be carried out using the PSK rather than +# the MQTT username/password and so password_file will not be used for this +# listener. +use_identity_as_username true + +# When using PSK, the encryption ciphers used will be chosen from the list of +# available PSK ciphers. If you want to control which ciphers are available, +# use the "ciphers" option. The list of available ciphers can be optained +# using the "openssl ciphers" command and should be provided in the same format +# as the output of that command. +#ciphers + +# ================================================================= +# Persistence +# ================================================================= + +# If persistence is enabled, save the in-memory database to disk +# every autosave_interval seconds. If set to 0, the persistence +# database will only be written when mosquitto exits. See also +# autosave_on_changes. +# Note that writing of the persistence database can be forced by +# sending mosquitto a SIGUSR1 signal. +#autosave_interval 1800 + +# If true, mosquitto will count the number of subscription changes, retained +# messages received and queued messages and if the total exceeds +# autosave_interval then the in-memory database will be saved to disk. +# If false, mosquitto will save the in-memory database to disk by treating +# autosave_interval as a time in seconds. +#autosave_on_changes false + +# Save persistent message data to disk (true/false). +# This saves information about all messages, including +# subscriptions, currently in-flight messages and retained +# messages. +# retained_persistence is a synonym for this option. +#persistence false + +# The filename to use for the persistent database, not including +# the path. +#persistence_file mosquitto.db + +# Location for persistent database. Must include trailing / +# Default is an empty string (current directory). +# Set to e.g. /var/lib/mosquitto/ if running as a proper service on Linux or +# similar. +#persistence_location + +# ================================================================= +# Logging +# ================================================================= + +# Places to log to. Use multiple log_dest lines for multiple +# logging destinations. +# Possible destinations are: stdout stderr syslog topic file +# +# stdout and stderr log to the console on the named output. +# +# syslog uses the userspace syslog facility which usually ends up +# in /var/log/messages or similar. +# +# topic logs to the broker topic '$SYS/broker/log/<severity>', +# where severity is one of D, E, W, N, I, M which are debug, error, +# warning, notice, information and message. Message type severity is used by +# the subscribe/unsubscribe log_types and publishes log messages to +# $SYS/broker/log/M/susbcribe or $SYS/broker/log/M/unsubscribe. +# +# The file destination requires an additional parameter which is the file to be +# logged to, e.g. "log_dest file /var/log/mosquitto.log". The file will be +# closed and reopened when the broker receives a HUP signal. Only a single file +# destination may be configured. +# +# Note that if the broker is running as a Windows service it will default to +# "log_dest none" and neither stdout nor stderr logging is available. +# Use "log_dest none" if you wish to disable logging. +#log_dest stderr + +# If using syslog logging (not on Windows), messages will be logged to the +# "daemon" facility by default. Use the log_facility option to choose which of +# local0 to local7 to log to instead. The option value should be an integer +# value, e.g. "log_facility 5" to use local5. +#log_facility + +# Types of messages to log. Use multiple log_type lines for logging +# multiple types of messages. +# Possible types are: debug, error, warning, notice, information, +# none, subscribe, unsubscribe, websockets, all. +# Note that debug type messages are for decoding the incoming/outgoing +# network packets. They are not logged in "topics". +#log_type error +#log_type warning +#log_type notice +#log_type information + +# Change the websockets logging level. This is a global option, it is not +# possible to set per listener. This is an integer that is interpreted by +# libwebsockets as a bit mask for its lws_log_levels enum. See the +# libwebsockets documentation for more details. "log_type websockets" must also +# be enabled. +#websockets_log_level 0 + +# If set to true, client connection and disconnection messages will be included +# in the log. +#connection_messages true + +# If set to true, add a timestamp value to each log message. +#log_timestamp true + +# ================================================================= +# Security +# ================================================================= + +# If set, only clients that have a matching prefix on their +# clientid will be allowed to connect to the broker. By default, +# all clients may connect. +# For example, setting "secure-" here would mean a client "secure- +# client" could connect but another with clientid "mqtt" couldn't. +#clientid_prefixes + +# Boolean value that determines whether clients that connect +# without providing a username are allowed to connect. If set to +# false then a password file should be created (see the +# password_file option) to control authenticated client access. +# Defaults to true. +allow_anonymous true + +# In addition to the clientid_prefixes, allow_anonymous and TLS +# authentication options, username based authentication is also +# possible. The default support is described in "Default +# authentication and topic access control" below. The auth_plugin +# allows another authentication method to be used. +# Specify the path to the loadable plugin and see the +# "Authentication and topic access plugin options" section below. +#auth_plugin + +# ----------------------------------------------------------------- +# Default authentication and topic access control +# ----------------------------------------------------------------- + +# Control access to the broker using a password file. This file can be +# generated using the mosquitto_passwd utility. If TLS support is not compiled +# into mosquitto (it is recommended that TLS support should be included) then +# plain text passwords are used, in which case the file should be a text file +# with lines in the format: +# username:password +# The password (and colon) may be omitted if desired, although this +# offers very little in the way of security. +# +# See the TLS client require_certificate and use_identity_as_username options +# for alternative authentication options. +#password_file + +# Access may also be controlled using a pre-shared-key file. This requires +# TLS-PSK support and a listener configured to use it. The file should be text +# lines in the format: +# identity:key +# The key should be in hexadecimal format without a leading "0x". +psk_file ./psk_file.txt + +# Control access to topics on the broker using an access control list +# file. If this parameter is defined then only the topics listed will +# have access. +# If the first character of a line of the ACL file is a # it is treated as a +# comment. +# Topic access is added with lines of the format: +# +# topic [read|write|readwrite] <topic> +# +# The access type is controlled using "read", "write" or "readwrite". This +# parameter is optional (unless <topic> contains a space character) - if not +# given then the access is read/write. <topic> can contain the + or # +# wildcards as in subscriptions. +# +# The first set of topics are applied to anonymous clients, assuming +# allow_anonymous is true. User specific topic ACLs are added after a +# user line as follows: +# +# user <username> +# +# The username referred to here is the same as in password_file. It is +# not the clientid. +# +# +# If is also possible to define ACLs based on pattern substitution within the +# topic. The patterns available for substition are: +# +# %c to match the client id of the client +# %u to match the username of the client +# +# The substitution pattern must be the only text for that level of hierarchy. +# +# The form is the same as for the topic keyword, but using pattern as the +# keyword. +# Pattern ACLs apply to all users even if the "user" keyword has previously +# been given. +# +# If using bridges with usernames and ACLs, connection messages can be allowed +# with the following pattern: +# pattern write $SYS/broker/connection/%c/state +# +# pattern [read|write|readwrite] <topic> +# +# Example: +# +# pattern write sensor/%u/data +# +#acl_file + +# ----------------------------------------------------------------- +# Authentication and topic access plugin options +# ----------------------------------------------------------------- + +# If the auth_plugin option above is used, define options to pass to the +# plugin here as described by the plugin instructions. All options named +# using the format auth_opt_* will be passed to the plugin, for example: +# +# auth_opt_db_host +# auth_opt_db_port +# auth_opt_db_username +# auth_opt_db_password + +# ================================================================= +# External config files +# ================================================================= + +# External configuration files may be included by using the +# include_dir option. This defines a directory that will be searched +# for config files. All files that end in '.conf' will be loaded as +# a configuration file. It is best to have this as the last option +# in the main file. This option will only be processed from the main +# configuration file. The directory specified must not contain the +# main configuration file. +#include_dir + +# ================================================================= +# rsmb options - unlikely to ever be supported +# ================================================================= + +#ffdc_output +#max_log_entries +#trace_level +#trace_output diff --git a/test/regression/interoperability_test/mqtt_test/test_scripts/mosquitto.conf b/test/regression/interoperability_test/mqtt_test/test_scripts/mosquitto.conf new file mode 100644 index 00000000..15a217f5 --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/test_scripts/mosquitto.conf @@ -0,0 +1,494 @@ +# Config file for mosquitto +# +# See mosquitto.conf(5) for more information. +# +# Default values are shown, uncomment to change. +# +# Use the # character to indicate a comment, but only if it is the +# very first character on the line. + +# ================================================================= +# General configuration +# ================================================================= + +# Time in seconds to wait before resending an outgoing QoS=1 or +# QoS=2 message. +#retry_interval 20 + +# Time in seconds between updates of the $SYS tree. +# Set to 0 to disable the publishing of the $SYS tree. +#sys_interval 10 + +# Time in seconds between cleaning the internal message store of +# unreferenced messages. Lower values will result in lower memory +# usage but more processor time, higher values will have the +# opposite effect. +# Setting a value of 0 means the unreferenced messages will be +# disposed of as quickly as possible. +#store_clean_interval 10 + +# Write process id to a file. Default is a blank string which means +# a pid file shouldn't be written. +# This should be set to /var/run/mosquitto.pid if mosquitto is +# being run automatically on boot with an init script and +# start-stop-daemon or similar. +#pid_file + +# When run as root, drop privileges to this user and its primary +# group. +# Leave blank to stay as root, but this is not recommended. +# If run as a non-root user, this setting has no effect. +# Note that on Windows this has no effect and so mosquitto should +# be started by the user you wish it to run as. +user root + +# The maximum number of QoS 1 and 2 messages currently inflight per +# client. +# This includes messages that are partway through handshakes and +# those that are being retried. Defaults to 20. Set to 0 for no +# maximum. Setting to 1 will guarantee in-order delivery of QoS 1 +# and 2 messages. +#max_inflight_messages 20 + +# The maximum number of QoS 1 and 2 messages to hold in a queue +# above those that are currently in-flight. Defaults to 100. Set +# to 0 for no maximum (not recommended). +# See also queue_qos0_messages. +#max_queued_messages 100 + +# Set to true to queue messages with QoS 0 when a persistent client is +# disconnected. These messages are included in the limit imposed by +# max_queued_messages. +# Defaults to false. +# This is a non-standard option for the MQTT v3.1 spec but is allowed in +# v3.1.1. +#queue_qos0_messages false + +# This option sets the maximum publish payload size that the broker will allow. +# Received messages that exceed this size will not be accepted by the broker. +# The default value is 0, which means that all valid MQTT messages are +# accepted. MQTT imposes a maximum payload size of 268435455 bytes. +#message_size_limit 0 + +# This option controls whether a client is allowed to connect with a zero +# length client id or not. This option only affects clients using MQTT v3.1.1 +# and later. If set to false, clients connecting with a zero length client id +# are disconnected. If set to true, clients will be allocated a client id by +# the broker. This means it is only useful for clients with clean session set +# to true. +#allow_zero_length_clientid true + +# If allow_zero_length_clientid is true, this option allows you to set a prefix +# to automatically generated client ids to aid visibility in logs. +#auto_id_prefix + +# This option allows persistent clients (those with clean session set to false) +# to be removed if they do not reconnect within a certain time frame. +# +# This is a non-standard option in MQTT V3.1 but allowed in MQTT v3.1.1. +# +# Badly designed clients may set clean session to false whilst using a randomly +# generated client id. This leads to persistent clients that will never +# reconnect. This option allows these clients to be removed. +# +# The expiration period should be an integer followed by one of h d w m y for +# hour, day, week, month and year respectively. For example +# +# persistent_client_expiration 2m +# persistent_client_expiration 14d +# persistent_client_expiration 1y +# +# The default if not set is to never expire persistent clients. +#persistent_client_expiration + +# If a client is subscribed to multiple subscriptions that overlap, e.g. foo/# +# and foo/+/baz , then MQTT expects that when the broker receives a message on +# a topic that matches both subscriptions, such as foo/bar/baz, then the client +# should only receive the message once. +# Mosquitto keeps track of which clients a message has been sent to in order to +# meet this requirement. The allow_duplicate_messages option allows this +# behaviour to be disabled, which may be useful if you have a large number of +# clients subscribed to the same set of topics and are very concerned about +# minimising memory usage. +# It can be safely set to true if you know in advance that your clients will +# never have overlapping subscriptions, otherwise your clients must be able to +# correctly deal with duplicate messages even when then have QoS=2. +#allow_duplicate_messages false + +# The MQTT specification requires that the QoS of a message delivered to a +# subscriber is never upgraded to match the QoS of the subscription. Enabling +# this option changes this behaviour. If upgrade_outgoing_qos is set true, +# messages sent to a subscriber will always match the QoS of its subscription. +# This is a non-standard option explicitly disallowed by the spec. +#upgrade_outgoing_qos false + +# ================================================================= +# Default listener +# ================================================================= + +# IP address/hostname to bind the default listener to. If not +# given, the default listener will not be bound to a specific +# address and so will be accessible to all network interfaces. +# bind_address ip-address/host name +#bind_address + +# Port to use for the default listener. +#port 1883 +listener 8884 + +# The maximum number of client connections to allow. This is +# a per listener setting. +# Default is -1, which means unlimited connections. +# Note that other process limits mean that unlimited connections +# are not really possible. Typically the default maximum number of +# connections possible is around 1024. +#max_connections -1 + +# Choose the protocol to use when listening. +# This can be either mqtt or websockets. +# Websockets support is currently disabled by default at compile time. +# Certificate based TLS may be used with websockets, except that +# only the cafile, certfile, keyfile and ciphers options are supported. +#protocol mqtt + +# When a listener is using the websockets protocol, it is possible to serve +# http data as well. Set http_dir to a directory which contains the files you +# wish to serve. If this option is not specified, then no normal http +# connections will be possible. +#http_dir + +# Set use_username_as_clientid to true to replace the clientid that a client +# connected with with its username. This allows authentication to be tied to +# the clientid, which means that it is possible to prevent one client +# disconnecting another by using the same clientid. +# If a client connects with no username it will be disconnected as not +# authorised when this option is set to true. +# Do not use in conjunction with clientid_prefixes. +# See also use_identity_as_username. +#use_username_as_clientid + +# ----------------------------------------------------------------- +# Certificate based SSL/TLS support +# ----------------------------------------------------------------- +# The following options can be used to enable SSL/TLS support for +# this listener. Note that the recommended port for MQTT over TLS +# is 8883, but this must be set manually. +# +# See also the mosquitto-tls man page. + +# At least one of cafile or capath must be defined. They both +# define methods of accessing the PEM encoded Certificate +# Authority certificates that have signed your server certificate +# and that you wish to trust. +# cafile defines the path to a file containing the CA certificates. +# capath defines a directory that will be searched for files +# containing the CA certificates. For capath to work correctly, the +# certificate files must have ".crt" as the file ending and you must run +# "c_rehash <path to capath>" each time you add/remove a certificate. +cafile CA/ca/ca.crt +#capath + +# Path to the PEM encoded server certificate. +#certfile ./cert.pem +certfile CA/certs/broker.server.crt + + +# Path to the PEM encoded keyfile. +#keyfile ./keyout.pem +keyfile CA/private/broker.server.key + +# This option defines the version of the TLS protocol to use for this listener. +# The default value allows v1.2, v1.1 and v1.0, if they are all supported by +# the version of openssl that the broker was compiled against. For openssl >= +# 1.0.1 the valid values are tlsv1.2 tlsv1.1 and tlsv1. For openssl < 1.0.1 the +# valid values are tlsv1. +#tls_version tlsv1.2 + +# By default a TLS enabled listener will operate in a similar fashion to a +# https enabled web server, in that the server has a certificate signed by a CA +# and the client will verify that it is a trusted certificate. The overall aim +# is encryption of the network traffic. By setting require_certificate to true, +# the client must provide a valid certificate in order for the network +# connection to proceed. This allows access to the broker to be controlled +# outside of the mechanisms provided by MQTT. +#require_certificate true + +# If require_certificate is true, you may set use_identity_as_username to true +# to use the CN value from the client certificate as a username. If this is +# true, the password_file option will not be used for this listener. +#use_identity_as_username false + +# If you have require_certificate set to true, you can create a certificate +# revocation list file to revoke access to particular client certificates. If +# you have done this, use crlfile to point to the PEM encoded revocation file. +#crlfile + +# If you wish to control which encryption ciphers are used, use the ciphers +# option. The list of available ciphers can be optained using the "openssl +# ciphers" command and should be provided in the same format as the output of +# that command. +# If unset defaults to DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:@STRENGTH +#ciphers DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:@STRENGTH + +# ----------------------------------------------------------------- +# Pre-shared-key based SSL/TLS support +# ----------------------------------------------------------------- +# The following options can be used to enable PSK based SSL/TLS support for +# this listener. Note that the recommended port for MQTT over TLS is 8883, but +# this must be set manually. +# +# See also the mosquitto-tls man page and the "Certificate based SSL/TLS +# support" section. Only one of certificate or PSK encryption support can be +# enabled for any listener. + +# The psk_hint option enables pre-shared-key support for this listener and also +# acts as an identifier for this listener. The hint is sent to clients and may +# be used locally to aid authentication. The hint is a free form string that +# doesn't have much meaning in itself, so feel free to be creative. +# If this option is provided, see psk_file to define the pre-shared keys to be +# used or create a security plugin to handle them. +#psk_hint Client_identity + +# Set use_identity_as_username to have the psk identity sent by the client used +# as its username. Authentication will be carried out using the PSK rather than +# the MQTT username/password and so password_file will not be used for this +# listener. +#use_identity_as_username true + +# When using PSK, the encryption ciphers used will be chosen from the list of +# available PSK ciphers. If you want to control which ciphers are available, +# use the "ciphers" option. The list of available ciphers can be optained +# using the "openssl ciphers" command and should be provided in the same format +# as the output of that command. +#ciphers + +# ================================================================= +# Persistence +# ================================================================= + +# If persistence is enabled, save the in-memory database to disk +# every autosave_interval seconds. If set to 0, the persistence +# database will only be written when mosquitto exits. See also +# autosave_on_changes. +# Note that writing of the persistence database can be forced by +# sending mosquitto a SIGUSR1 signal. +#autosave_interval 1800 + +# If true, mosquitto will count the number of subscription changes, retained +# messages received and queued messages and if the total exceeds +# autosave_interval then the in-memory database will be saved to disk. +# If false, mosquitto will save the in-memory database to disk by treating +# autosave_interval as a time in seconds. +#autosave_on_changes false + +# Save persistent message data to disk (true/false). +# This saves information about all messages, including +# subscriptions, currently in-flight messages and retained +# messages. +# retained_persistence is a synonym for this option. +#persistence false + +# The filename to use for the persistent database, not including +# the path. +#persistence_file mosquitto.db + +# Location for persistent database. Must include trailing / +# Default is an empty string (current directory). +# Set to e.g. /var/lib/mosquitto/ if running as a proper service on Linux or +# similar. +#persistence_location + +# ================================================================= +# Logging +# ================================================================= + +# Places to log to. Use multiple log_dest lines for multiple +# logging destinations. +# Possible destinations are: stdout stderr syslog topic file +# +# stdout and stderr log to the console on the named output. +# +# syslog uses the userspace syslog facility which usually ends up +# in /var/log/messages or similar. +# +# topic logs to the broker topic '$SYS/broker/log/<severity>', +# where severity is one of D, E, W, N, I, M which are debug, error, +# warning, notice, information and message. Message type severity is used by +# the subscribe/unsubscribe log_types and publishes log messages to +# $SYS/broker/log/M/susbcribe or $SYS/broker/log/M/unsubscribe. +# +# The file destination requires an additional parameter which is the file to be +# logged to, e.g. "log_dest file /var/log/mosquitto.log". The file will be +# closed and reopened when the broker receives a HUP signal. Only a single file +# destination may be configured. +# +# Note that if the broker is running as a Windows service it will default to +# "log_dest none" and neither stdout nor stderr logging is available. +# Use "log_dest none" if you wish to disable logging. +#log_dest stderr + +# If using syslog logging (not on Windows), messages will be logged to the +# "daemon" facility by default. Use the log_facility option to choose which of +# local0 to local7 to log to instead. The option value should be an integer +# value, e.g. "log_facility 5" to use local5. +#log_facility + +# Types of messages to log. Use multiple log_type lines for logging +# multiple types of messages. +# Possible types are: debug, error, warning, notice, information, +# none, subscribe, unsubscribe, websockets, all. +# Note that debug type messages are for decoding the incoming/outgoing +# network packets. They are not logged in "topics". +#log_type error +#log_type warning +#log_type notice +#log_type information + +# Change the websockets logging level. This is a global option, it is not +# possible to set per listener. This is an integer that is interpreted by +# libwebsockets as a bit mask for its lws_log_levels enum. See the +# libwebsockets documentation for more details. "log_type websockets" must also +# be enabled. +#websockets_log_level 0 + +# If set to true, client connection and disconnection messages will be included +# in the log. +#connection_messages true + +# If set to true, add a timestamp value to each log message. +#log_timestamp true + +# ================================================================= +# Security +# ================================================================= + +# If set, only clients that have a matching prefix on their +# clientid will be allowed to connect to the broker. By default, +# all clients may connect. +# For example, setting "secure-" here would mean a client "secure- +# client" could connect but another with clientid "mqtt" couldn't. +#clientid_prefixes + +# Boolean value that determines whether clients that connect +# without providing a username are allowed to connect. If set to +# false then a password file should be created (see the +# password_file option) to control authenticated client access. +# Defaults to true. +allow_anonymous true + +# In addition to the clientid_prefixes, allow_anonymous and TLS +# authentication options, username based authentication is also +# possible. The default support is described in "Default +# authentication and topic access control" below. The auth_plugin +# allows another authentication method to be used. +# Specify the path to the loadable plugin and see the +# "Authentication and topic access plugin options" section below. +#auth_plugin + +# ----------------------------------------------------------------- +# Default authentication and topic access control +# ----------------------------------------------------------------- + +# Control access to the broker using a password file. This file can be +# generated using the mosquitto_passwd utility. If TLS support is not compiled +# into mosquitto (it is recommended that TLS support should be included) then +# plain text passwords are used, in which case the file should be a text file +# with lines in the format: +# username:password +# The password (and colon) may be omitted if desired, although this +# offers very little in the way of security. +# +# See the TLS client require_certificate and use_identity_as_username options +# for alternative authentication options. +#password_file + +# Access may also be controlled using a pre-shared-key file. This requires +# TLS-PSK support and a listener configured to use it. The file should be text +# lines in the format: +# identity:key +# The key should be in hexadecimal format without a leading "0x". +#psk_file ./psk_file.txt + +# Control access to topics on the broker using an access control list +# file. If this parameter is defined then only the topics listed will +# have access. +# If the first character of a line of the ACL file is a # it is treated as a +# comment. +# Topic access is added with lines of the format: +# +# topic [read|write|readwrite] <topic> +# +# The access type is controlled using "read", "write" or "readwrite". This +# parameter is optional (unless <topic> contains a space character) - if not +# given then the access is read/write. <topic> can contain the + or # +# wildcards as in subscriptions. +# +# The first set of topics are applied to anonymous clients, assuming +# allow_anonymous is true. User specific topic ACLs are added after a +# user line as follows: +# +# user <username> +# +# The username referred to here is the same as in password_file. It is +# not the clientid. +# +# +# If is also possible to define ACLs based on pattern substitution within the +# topic. The patterns available for substition are: +# +# %c to match the client id of the client +# %u to match the username of the client +# +# The substitution pattern must be the only text for that level of hierarchy. +# +# The form is the same as for the topic keyword, but using pattern as the +# keyword. +# Pattern ACLs apply to all users even if the "user" keyword has previously +# been given. +# +# If using bridges with usernames and ACLs, connection messages can be allowed +# with the following pattern: +# pattern write $SYS/broker/connection/%c/state +# +# pattern [read|write|readwrite] <topic> +# +# Example: +# +# pattern write sensor/%u/data +# +#acl_file + +# ----------------------------------------------------------------- +# Authentication and topic access plugin options +# ----------------------------------------------------------------- + +# If the auth_plugin option above is used, define options to pass to the +# plugin here as described by the plugin instructions. All options named +# using the format auth_opt_* will be passed to the plugin, for example: +# +# auth_opt_db_host +# auth_opt_db_port +# auth_opt_db_username +# auth_opt_db_password + +# ================================================================= +# External config files +# ================================================================= + +# External configuration files may be included by using the +# include_dir option. This defines a directory that will be searched +# for config files. All files that end in '.conf' will be loaded as +# a configuration file. It is best to have this as the last option +# in the main file. This option will only be processed from the main +# configuration file. The directory specified must not contain the +# main configuration file. +#include_dir + +# ================================================================= +# rsmb options - unlikely to ever be supported +# ================================================================= + +#ffdc_output +#max_log_entries +#trace_level +#trace_output diff --git a/test/regression/interoperability_test/mqtt_test/test_scripts/mosquitto_no_tls.conf b/test/regression/interoperability_test/mqtt_test/test_scripts/mosquitto_no_tls.conf new file mode 100644 index 00000000..15047b65 --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/test_scripts/mosquitto_no_tls.conf @@ -0,0 +1,494 @@ +# Config file for mosquitto +# +# See mosquitto.conf(5) for more information. +# +# Default values are shown, uncomment to change. +# +# Use the # character to indicate a comment, but only if it is the +# very first character on the line. + +# ================================================================= +# General configuration +# ================================================================= + +# Time in seconds to wait before resending an outgoing QoS=1 or +# QoS=2 message. +#retry_interval 20 + +# Time in seconds between updates of the $SYS tree. +# Set to 0 to disable the publishing of the $SYS tree. +#sys_interval 10 + +# Time in seconds between cleaning the internal message store of +# unreferenced messages. Lower values will result in lower memory +# usage but more processor time, higher values will have the +# opposite effect. +# Setting a value of 0 means the unreferenced messages will be +# disposed of as quickly as possible. +#store_clean_interval 10 + +# Write process id to a file. Default is a blank string which means +# a pid file shouldn't be written. +# This should be set to /var/run/mosquitto.pid if mosquitto is +# being run automatically on boot with an init script and +# start-stop-daemon or similar. +#pid_file + +# When run as root, drop privileges to this user and its primary +# group. +# Leave blank to stay as root, but this is not recommended. +# If run as a non-root user, this setting has no effect. +# Note that on Windows this has no effect and so mosquitto should +# be started by the user you wish it to run as. +user root + +# The maximum number of QoS 1 and 2 messages currently inflight per +# client. +# This includes messages that are partway through handshakes and +# those that are being retried. Defaults to 20. Set to 0 for no +# maximum. Setting to 1 will guarantee in-order delivery of QoS 1 +# and 2 messages. +#max_inflight_messages 20 + +# The maximum number of QoS 1 and 2 messages to hold in a queue +# above those that are currently in-flight. Defaults to 100. Set +# to 0 for no maximum (not recommended). +# See also queue_qos0_messages. +#max_queued_messages 100 + +# Set to true to queue messages with QoS 0 when a persistent client is +# disconnected. These messages are included in the limit imposed by +# max_queued_messages. +# Defaults to false. +# This is a non-standard option for the MQTT v3.1 spec but is allowed in +# v3.1.1. +#queue_qos0_messages false + +# This option sets the maximum publish payload size that the broker will allow. +# Received messages that exceed this size will not be accepted by the broker. +# The default value is 0, which means that all valid MQTT messages are +# accepted. MQTT imposes a maximum payload size of 268435455 bytes. +#message_size_limit 0 + +# This option controls whether a client is allowed to connect with a zero +# length client id or not. This option only affects clients using MQTT v3.1.1 +# and later. If set to false, clients connecting with a zero length client id +# are disconnected. If set to true, clients will be allocated a client id by +# the broker. This means it is only useful for clients with clean session set +# to true. +#allow_zero_length_clientid true + +# If allow_zero_length_clientid is true, this option allows you to set a prefix +# to automatically generated client ids to aid visibility in logs. +#auto_id_prefix + +# This option allows persistent clients (those with clean session set to false) +# to be removed if they do not reconnect within a certain time frame. +# +# This is a non-standard option in MQTT V3.1 but allowed in MQTT v3.1.1. +# +# Badly designed clients may set clean session to false whilst using a randomly +# generated client id. This leads to persistent clients that will never +# reconnect. This option allows these clients to be removed. +# +# The expiration period should be an integer followed by one of h d w m y for +# hour, day, week, month and year respectively. For example +# +# persistent_client_expiration 2m +# persistent_client_expiration 14d +# persistent_client_expiration 1y +# +# The default if not set is to never expire persistent clients. +#persistent_client_expiration + +# If a client is subscribed to multiple subscriptions that overlap, e.g. foo/# +# and foo/+/baz , then MQTT expects that when the broker receives a message on +# a topic that matches both subscriptions, such as foo/bar/baz, then the client +# should only receive the message once. +# Mosquitto keeps track of which clients a message has been sent to in order to +# meet this requirement. The allow_duplicate_messages option allows this +# behaviour to be disabled, which may be useful if you have a large number of +# clients subscribed to the same set of topics and are very concerned about +# minimising memory usage. +# It can be safely set to true if you know in advance that your clients will +# never have overlapping subscriptions, otherwise your clients must be able to +# correctly deal with duplicate messages even when then have QoS=2. +#allow_duplicate_messages false + +# The MQTT specification requires that the QoS of a message delivered to a +# subscriber is never upgraded to match the QoS of the subscription. Enabling +# this option changes this behaviour. If upgrade_outgoing_qos is set true, +# messages sent to a subscriber will always match the QoS of its subscription. +# This is a non-standard option explicitly disallowed by the spec. +#upgrade_outgoing_qos false + +# ================================================================= +# Default listener +# ================================================================= + +# IP address/hostname to bind the default listener to. If not +# given, the default listener will not be bound to a specific +# address and so will be accessible to all network interfaces. +# bind_address ip-address/host name +#bind_address + +# Port to use for the default listener. +#port 1883 +listener 8884 + +# The maximum number of client connections to allow. This is +# a per listener setting. +# Default is -1, which means unlimited connections. +# Note that other process limits mean that unlimited connections +# are not really possible. Typically the default maximum number of +# connections possible is around 1024. +#max_connections -1 + +# Choose the protocol to use when listening. +# This can be either mqtt or websockets. +# Websockets support is currently disabled by default at compile time. +# Certificate based TLS may be used with websockets, except that +# only the cafile, certfile, keyfile and ciphers options are supported. +#protocol mqtt + +# When a listener is using the websockets protocol, it is possible to serve +# http data as well. Set http_dir to a directory which contains the files you +# wish to serve. If this option is not specified, then no normal http +# connections will be possible. +#http_dir + +# Set use_username_as_clientid to true to replace the clientid that a client +# connected with with its username. This allows authentication to be tied to +# the clientid, which means that it is possible to prevent one client +# disconnecting another by using the same clientid. +# If a client connects with no username it will be disconnected as not +# authorised when this option is set to true. +# Do not use in conjunction with clientid_prefixes. +# See also use_identity_as_username. +#use_username_as_clientid + +# ----------------------------------------------------------------- +# Certificate based SSL/TLS support +# ----------------------------------------------------------------- +# The following options can be used to enable SSL/TLS support for +# this listener. Note that the recommended port for MQTT over TLS +# is 8883, but this must be set manually. +# +# See also the mosquitto-tls man page. + +# At least one of cafile or capath must be defined. They both +# define methods of accessing the PEM encoded Certificate +# Authority certificates that have signed your server certificate +# and that you wish to trust. +# cafile defines the path to a file containing the CA certificates. +# capath defines a directory that will be searched for files +# containing the CA certificates. For capath to work correctly, the +# certificate files must have ".crt" as the file ending and you must run +# "c_rehash <path to capath>" each time you add/remove a certificate. +#cafile CA/ca/ca.crt +#capath + +# Path to the PEM encoded server certificate. +#certfile ./cert.pem +#certfile CA/certs/broker.server.crt + + +# Path to the PEM encoded keyfile. +#keyfile ./keyout.pem +#keyfile CA/private/broker.server.key + +# This option defines the version of the TLS protocol to use for this listener. +# The default value allows v1.2, v1.1 and v1.0, if they are all supported by +# the version of openssl that the broker was compiled against. For openssl >= +# 1.0.1 the valid values are tlsv1.2 tlsv1.1 and tlsv1. For openssl < 1.0.1 the +# valid values are tlsv1. +#tls_version tlsv1.2 + +# By default a TLS enabled listener will operate in a similar fashion to a +# https enabled web server, in that the server has a certificate signed by a CA +# and the client will verify that it is a trusted certificate. The overall aim +# is encryption of the network traffic. By setting require_certificate to true, +# the client must provide a valid certificate in order for the network +# connection to proceed. This allows access to the broker to be controlled +# outside of the mechanisms provided by MQTT. +#require_certificate true + +# If require_certificate is true, you may set use_identity_as_username to true +# to use the CN value from the client certificate as a username. If this is +# true, the password_file option will not be used for this listener. +#use_identity_as_username false + +# If you have require_certificate set to true, you can create a certificate +# revocation list file to revoke access to particular client certificates. If +# you have done this, use crlfile to point to the PEM encoded revocation file. +#crlfile + +# If you wish to control which encryption ciphers are used, use the ciphers +# option. The list of available ciphers can be optained using the "openssl +# ciphers" command and should be provided in the same format as the output of +# that command. +# If unset defaults to DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:@STRENGTH +#ciphers DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:@STRENGTH + +# ----------------------------------------------------------------- +# Pre-shared-key based SSL/TLS support +# ----------------------------------------------------------------- +# The following options can be used to enable PSK based SSL/TLS support for +# this listener. Note that the recommended port for MQTT over TLS is 8883, but +# this must be set manually. +# +# See also the mosquitto-tls man page and the "Certificate based SSL/TLS +# support" section. Only one of certificate or PSK encryption support can be +# enabled for any listener. + +# The psk_hint option enables pre-shared-key support for this listener and also +# acts as an identifier for this listener. The hint is sent to clients and may +# be used locally to aid authentication. The hint is a free form string that +# doesn't have much meaning in itself, so feel free to be creative. +# If this option is provided, see psk_file to define the pre-shared keys to be +# used or create a security plugin to handle them. +#psk_hint Client_identity + +# Set use_identity_as_username to have the psk identity sent by the client used +# as its username. Authentication will be carried out using the PSK rather than +# the MQTT username/password and so password_file will not be used for this +# listener. +#use_identity_as_username true + +# When using PSK, the encryption ciphers used will be chosen from the list of +# available PSK ciphers. If you want to control which ciphers are available, +# use the "ciphers" option. The list of available ciphers can be optained +# using the "openssl ciphers" command and should be provided in the same format +# as the output of that command. +#ciphers + +# ================================================================= +# Persistence +# ================================================================= + +# If persistence is enabled, save the in-memory database to disk +# every autosave_interval seconds. If set to 0, the persistence +# database will only be written when mosquitto exits. See also +# autosave_on_changes. +# Note that writing of the persistence database can be forced by +# sending mosquitto a SIGUSR1 signal. +#autosave_interval 1800 + +# If true, mosquitto will count the number of subscription changes, retained +# messages received and queued messages and if the total exceeds +# autosave_interval then the in-memory database will be saved to disk. +# If false, mosquitto will save the in-memory database to disk by treating +# autosave_interval as a time in seconds. +#autosave_on_changes false + +# Save persistent message data to disk (true/false). +# This saves information about all messages, including +# subscriptions, currently in-flight messages and retained +# messages. +# retained_persistence is a synonym for this option. +#persistence false + +# The filename to use for the persistent database, not including +# the path. +#persistence_file mosquitto.db + +# Location for persistent database. Must include trailing / +# Default is an empty string (current directory). +# Set to e.g. /var/lib/mosquitto/ if running as a proper service on Linux or +# similar. +#persistence_location + +# ================================================================= +# Logging +# ================================================================= + +# Places to log to. Use multiple log_dest lines for multiple +# logging destinations. +# Possible destinations are: stdout stderr syslog topic file +# +# stdout and stderr log to the console on the named output. +# +# syslog uses the userspace syslog facility which usually ends up +# in /var/log/messages or similar. +# +# topic logs to the broker topic '$SYS/broker/log/<severity>', +# where severity is one of D, E, W, N, I, M which are debug, error, +# warning, notice, information and message. Message type severity is used by +# the subscribe/unsubscribe log_types and publishes log messages to +# $SYS/broker/log/M/susbcribe or $SYS/broker/log/M/unsubscribe. +# +# The file destination requires an additional parameter which is the file to be +# logged to, e.g. "log_dest file /var/log/mosquitto.log". The file will be +# closed and reopened when the broker receives a HUP signal. Only a single file +# destination may be configured. +# +# Note that if the broker is running as a Windows service it will default to +# "log_dest none" and neither stdout nor stderr logging is available. +# Use "log_dest none" if you wish to disable logging. +#log_dest stderr + +# If using syslog logging (not on Windows), messages will be logged to the +# "daemon" facility by default. Use the log_facility option to choose which of +# local0 to local7 to log to instead. The option value should be an integer +# value, e.g. "log_facility 5" to use local5. +#log_facility + +# Types of messages to log. Use multiple log_type lines for logging +# multiple types of messages. +# Possible types are: debug, error, warning, notice, information, +# none, subscribe, unsubscribe, websockets, all. +# Note that debug type messages are for decoding the incoming/outgoing +# network packets. They are not logged in "topics". +#log_type error +#log_type warning +#log_type notice +#log_type information + +# Change the websockets logging level. This is a global option, it is not +# possible to set per listener. This is an integer that is interpreted by +# libwebsockets as a bit mask for its lws_log_levels enum. See the +# libwebsockets documentation for more details. "log_type websockets" must also +# be enabled. +#websockets_log_level 0 + +# If set to true, client connection and disconnection messages will be included +# in the log. +#connection_messages true + +# If set to true, add a timestamp value to each log message. +#log_timestamp true + +# ================================================================= +# Security +# ================================================================= + +# If set, only clients that have a matching prefix on their +# clientid will be allowed to connect to the broker. By default, +# all clients may connect. +# For example, setting "secure-" here would mean a client "secure- +# client" could connect but another with clientid "mqtt" couldn't. +#clientid_prefixes + +# Boolean value that determines whether clients that connect +# without providing a username are allowed to connect. If set to +# false then a password file should be created (see the +# password_file option) to control authenticated client access. +# Defaults to true. +allow_anonymous true + +# In addition to the clientid_prefixes, allow_anonymous and TLS +# authentication options, username based authentication is also +# possible. The default support is described in "Default +# authentication and topic access control" below. The auth_plugin +# allows another authentication method to be used. +# Specify the path to the loadable plugin and see the +# "Authentication and topic access plugin options" section below. +#auth_plugin + +# ----------------------------------------------------------------- +# Default authentication and topic access control +# ----------------------------------------------------------------- + +# Control access to the broker using a password file. This file can be +# generated using the mosquitto_passwd utility. If TLS support is not compiled +# into mosquitto (it is recommended that TLS support should be included) then +# plain text passwords are used, in which case the file should be a text file +# with lines in the format: +# username:password +# The password (and colon) may be omitted if desired, although this +# offers very little in the way of security. +# +# See the TLS client require_certificate and use_identity_as_username options +# for alternative authentication options. +#password_file + +# Access may also be controlled using a pre-shared-key file. This requires +# TLS-PSK support and a listener configured to use it. The file should be text +# lines in the format: +# identity:key +# The key should be in hexadecimal format without a leading "0x". +#psk_file ./psk_file.txt + +# Control access to topics on the broker using an access control list +# file. If this parameter is defined then only the topics listed will +# have access. +# If the first character of a line of the ACL file is a # it is treated as a +# comment. +# Topic access is added with lines of the format: +# +# topic [read|write|readwrite] <topic> +# +# The access type is controlled using "read", "write" or "readwrite". This +# parameter is optional (unless <topic> contains a space character) - if not +# given then the access is read/write. <topic> can contain the + or # +# wildcards as in subscriptions. +# +# The first set of topics are applied to anonymous clients, assuming +# allow_anonymous is true. User specific topic ACLs are added after a +# user line as follows: +# +# user <username> +# +# The username referred to here is the same as in password_file. It is +# not the clientid. +# +# +# If is also possible to define ACLs based on pattern substitution within the +# topic. The patterns available for substition are: +# +# %c to match the client id of the client +# %u to match the username of the client +# +# The substitution pattern must be the only text for that level of hierarchy. +# +# The form is the same as for the topic keyword, but using pattern as the +# keyword. +# Pattern ACLs apply to all users even if the "user" keyword has previously +# been given. +# +# If using bridges with usernames and ACLs, connection messages can be allowed +# with the following pattern: +# pattern write $SYS/broker/connection/%c/state +# +# pattern [read|write|readwrite] <topic> +# +# Example: +# +# pattern write sensor/%u/data +# +#acl_file + +# ----------------------------------------------------------------- +# Authentication and topic access plugin options +# ----------------------------------------------------------------- + +# If the auth_plugin option above is used, define options to pass to the +# plugin here as described by the plugin instructions. All options named +# using the format auth_opt_* will be passed to the plugin, for example: +# +# auth_opt_db_host +# auth_opt_db_port +# auth_opt_db_username +# auth_opt_db_password + +# ================================================================= +# External config files +# ================================================================= + +# External configuration files may be included by using the +# include_dir option. This defines a directory that will be searched +# for config files. All files that end in '.conf' will be loaded as +# a configuration file. It is best to have this as the last option +# in the main file. This option will only be processed from the main +# configuration file. The directory specified must not contain the +# main configuration file. +#include_dir + +# ================================================================= +# rsmb options - unlikely to ever be supported +# ================================================================= + +#ffdc_output +#max_log_entries +#trace_level +#trace_output diff --git a/test/regression/interoperability_test/mqtt_test/test_scripts/no_tls_pub.sh b/test/regression/interoperability_test/mqtt_test/test_scripts/no_tls_pub.sh new file mode 100755 index 00000000..34211a3e --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/test_scripts/no_tls_pub.sh @@ -0,0 +1,5 @@ +#! /bin/sh +dir=`dirname $0` +dir=`realpath $dir` +cd $dir +mosquitto_pub $* diff --git a/test/regression/interoperability_test/mqtt_test/test_scripts/no_tls_server.sh b/test/regression/interoperability_test/mqtt_test/test_scripts/no_tls_server.sh new file mode 100755 index 00000000..b04593a5 --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/test_scripts/no_tls_server.sh @@ -0,0 +1,14 @@ +#! /bin/bash + +function kill_mqtt_server(){ + kill $mqtt_server_pid + wait +} + +dir=`dirname $0` +dir=`realpath $dir` +cd $dir +mosquitto -c ./mosquitto_no_tls.conf -v $* & +mqtt_server_pid=$! +trap kill_mqtt_server TERM ALRM +wait diff --git a/test/regression/interoperability_test/mqtt_test/test_scripts/no_tls_sub.sh b/test/regression/interoperability_test/mqtt_test/test_scripts/no_tls_sub.sh new file mode 100755 index 00000000..52be4a76 --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/test_scripts/no_tls_sub.sh @@ -0,0 +1,5 @@ +#! /bin/sh +dir=`dirname $0` +dir=`realpath $dir` +cd $dir +mosquitto_sub -p 8883 $* diff --git a/test/regression/interoperability_test/mqtt_test/test_scripts/psk_server.sh b/test/regression/interoperability_test/mqtt_test/test_scripts/psk_server.sh new file mode 100644 index 00000000..ce9691b8 --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/test_scripts/psk_server.sh @@ -0,0 +1 @@ +../mosquitto-1.4.10/src/mosquitto.exe -c ./mosquitto-psk.conf -v -p 8883 diff --git a/test/regression/interoperability_test/mqtt_test/test_scripts/pub.sh b/test/regression/interoperability_test/mqtt_test/test_scripts/pub.sh new file mode 100755 index 00000000..8e0eae0a --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/test_scripts/pub.sh @@ -0,0 +1,5 @@ +#! /bin/sh +dir=`dirname $0` +dir=`realpath $dir` +cd $dir +mosquitto_pub --cert CA/certs/ew2017.client.crt --key CA/private/ew2017.client.key --cafile CA/ca/ca.crt --insecure $* diff --git a/test/regression/interoperability_test/mqtt_test/test_scripts/sub.sh b/test/regression/interoperability_test/mqtt_test/test_scripts/sub.sh new file mode 100755 index 00000000..83b95e34 --- /dev/null +++ b/test/regression/interoperability_test/mqtt_test/test_scripts/sub.sh @@ -0,0 +1,5 @@ +#! /bin/sh +dir=`dirname $0` +dir=`realpath $dir` +cd $dir +mosquitto_sub --cert CA/certs/ew2017.client.crt --key CA/private/ew2017.client.key --cafile CA/ca/ca.crt -p 8883 --insecure $* |
