Skip to content

Commit

Permalink
Adding X509 PEM support for Provisioning Client (#2229)
Browse files Browse the repository at this point in the history
* Adding DPS X509 public APIs. Splitting RIOT vs X509 tests.

* Adding UT for x509 HSM.

* Adding E2E tests.

* Adding OpenSSL ENGINE tests for DPS.

* Adding DevOps infra.

* Doc changes.

* Apply suggestions from code review

Co-authored-by: Eric Wolz <ericwol@microsoft.com>

* Fixing cmake integration issue

* Fixing vsts job name.

* Fixing Windows build. Removing DPS TPM and SAS for now.

* Adding HSM type configurations for all HSMs.

* Enabling DPS client by default.

* Addressing feedback around const and malloc/free.

* Fixing prov service client comment bug. Disabling prov_client on XCode.

* Fixing x509 sample when using trusted certificates.

* Fixing options test

* Adding test result publishing to all VSTS jobs.

* Changing test scripts to output ctest Test.xml logs.

* Disabling Provisioning Service Client tests failing on OSX.

* Fixing build scripts and test yaml definition.

* Apply suggestions from code review

Co-authored-by: Dane Walton <dawalton@microsoft.com>

* Resolving PR comments.

* Disabling two SFC tests failing leak checking. Tracked by #2238

Co-authored-by: Eric Wolz <ericwol@microsoft.com>
Co-authored-by: Dane Walton <dawalton@microsoft.com>
  • Loading branch information
3 people authored Feb 19, 2022
1 parent 7997430 commit 1de399f
Show file tree
Hide file tree
Showing 58 changed files with 2,539 additions and 638 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ common/tools/macro_utils_h_generator/macro_utils_h_generator.exe
build_all/windows/nuget.exe

/cmake
/build
**/build
*.cert
/.vs

Expand Down
17 changes: 11 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ IF(WIN32)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()


########### CMake Options ###########
# Testing
option(run_e2e_tests "set run_e2e_tests to ON to run e2e tests (default is OFF)" OFF)
Expand All @@ -58,16 +59,17 @@ option(use_installed_dependencies "set use_installed_dependencies to ON to use i
option(warnings_as_errors "enable strict compiler warnings-as-errors" ON)
option(build_as_dynamic "build the IoT SDK libaries as dynamic" OFF)
# Turn on/off IoT features
option(use_prov_client "Enable provisioning client" OFF)
option(use_prov_client "Enable provisioning client" ON)
option(use_tpm_simulator "tpm simulator type of hsm used with the provisioning client" OFF)
option(use_edge_modules "Enable support for running modules against Azure IoT Edge" OFF)
option(use_custom_heap "use externally defined heap functions instead of the malloc family" OFF)
option(build_service_client "controls whether the iothub_service_client is built or not" ON)
option(build_provisioning_service_client "controls whether the provisioning_service_client is built or not" ON)
# HSM Type
option(hsm_type_x509 "x509 type of hsm used with the Provisioning client" OFF)
option(hsm_type_sastoken "tpm type of hsm used with the Provisioning client" OFF)
option(hsm_type_symm_key "Symmetric key type of hsm used with the Provisioning client" OFF)
option(hsm_type_x509 "x509 type of hsm used with the Provisioning client" ON)
option(hsm_type_riot "DICE/RIoT x509 type of hsm used with the Provisioning client" OFF)
option(hsm_type_sastoken "tpm type of hsm used with the Provisioning client" ON)
option(hsm_type_symm_key "Symmetric key type of hsm used with the Provisioning client" ON)
option(hsm_type_custom "hsm type of custom used with the Provisioning client" OFF)
# Transport
option(use_amqp "set use_amqp to ON if amqp is to be used, set to OFF to not use amqp" ON)
Expand Down Expand Up @@ -135,7 +137,6 @@ if(${use_custom_heap})
add_definitions(-DGB_USE_CUSTOM_HEAP)
endif()

########## Enable Specific Root Certs ##########
if (${use_azure_cloud_rsa_cert})
add_definitions(-DUSE_AZURE_CLOUD_RSA_CERT)
endif()
Expand Down Expand Up @@ -176,7 +177,7 @@ if (${use_prov_client})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_PROV_MODULE_FULL")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_PROV_MODULE_FULL")
if ("${hsm_custom_lib}" STREQUAL "")
if ((NOT ${hsm_type_x509}) AND (NOT ${hsm_type_sastoken}) AND (NOT ${hsm_type_symm_key}))
if ((NOT ${hsm_type_x509}) AND (NOT ${hsm_type_sastoken}) AND (NOT ${hsm_type_symm_key}) AND (NOT ${hsm_type_riot}))
# If the cmake option did not explicitly configure an hsm type, then enable them all.
set(hsm_type_x509 ON)
set(hsm_type_sastoken ON)
Expand Down Expand Up @@ -204,6 +205,10 @@ if (NOT ${use_amqp} AND NOT ${use_http} AND NOT ${use_mqtt})
message(FATAL_ERROR "CMAKE Failure: AMQP, HTTP & MQTT are all disabled, IoT Hub Client must have one protocol enabled.")
endif()

if (${hsm_type_x509} AND ${hsm_type_riot})
message(FATAL_ERROR "CMAKE Failure: hsm_type_x509 and hsm_type_riot are incompatible. Select only one X509 HSM type.")
endif()

if (${dont_use_uploadtoblob})
add_definitions(-DDONT_USE_UPLOADTOBLOB)
endif()
Expand Down
214 changes: 202 additions & 12 deletions build/.vsts-ci.yml

Large diffs are not rendered by default.

17 changes: 15 additions & 2 deletions build_all/linux/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#

set -e
set -x

script_dir=$(cd "$(dirname "$0")" && pwd)
build_root=$(cd "${script_dir}/../.." && pwd)
Expand All @@ -24,6 +25,10 @@ no_logging=OFF
prov_auth=OFF
prov_use_tpm_simulator=OFF
use_edge_modules=OFF
hsm_type_sastoken=OFF
hsm_type_symm_key=OFF
hsm_type_x509=OFF
hsm_type_riot=OFF

usage ()
{
Expand All @@ -47,7 +52,11 @@ usage ()
echo " --no-logging Disable logging"
echo " --provisioning Use Provisioning with Flow"
echo " --use-tpm-simulator Build TPM simulator"
echo " --use-edge-modules Build Edge modules"
echo " --use-edge-modules Build Edge modules"
echo " --use-hsmsymmkey Build with HSM for Symmetric Key"
echo " --use-hsmsas Build with HSM for TPM"
echo " --use-hsmx509 Build with HSM for X509 Client Authentication"
echo " --use-hsmriot Build with HSM for RIoT/DICE"
exit 1
}

Expand Down Expand Up @@ -92,6 +101,10 @@ process_args ()
"--use-tpm-simulator" ) prov_use_tpm_simulator=ON;;
"--run-sfc-tests" ) run_sfc_tests=ON;;
"--use-edge-modules") use_edge_modules=ON;;
"--use-hsmsymmkey") hsm_type_symm_key=ON;;
"--use-hsmsas") hsm_type_sastoken=ON;;
"--use-hsmx509") hsm_type_riot=OFF; hsm_type_x509=ON;;
"--use-hsmriot") hsm_type_riot=ON; hsm_type_x509=OFF;;
* ) usage;;
esac
fi
Expand All @@ -115,7 +128,7 @@ rm -r -f $build_folder
mkdir -m777 -p $build_folder
pushd $build_folder
echo "Generating Build Files"
cmake $toolchainfile $cmake_install_prefix -Drun_valgrind:BOOL=$run_valgrind -DcompileOption_C=-Wstrict-prototypes -DcompileOption_C:STRING="$extracloptions" -Drun_e2e_tests:BOOL=$run_e2e_tests -Drun_sfc_tests:BOOL=$run-sfc-tests -Drun_longhaul_tests=$run_longhaul_tests -Duse_amqp:BOOL=$build_amqp -Duse_http:BOOL=$build_http -Duse_mqtt:BOOL=$build_mqtt -Ddont_use_uploadtoblob:BOOL=$no_blob -Drun_unittests:BOOL=$run_unittests -Dno_logging:BOOL=$no_logging $build_root -Duse_prov_client:BOOL=$prov_auth -Duse_tpm_simulator:BOOL=$prov_use_tpm_simulator -Duse_edge_modules=$use_edge_modules
cmake $toolchainfile $cmake_install_prefix $build_root -Drun_valgrind:BOOL=$run_valgrind -DcompileOption_C=-Wstrict-prototypes -DcompileOption_C:STRING="$extracloptions" -Drun_e2e_tests:BOOL=$run_e2e_tests -Drun_sfc_tests:BOOL=$run_sfc_tests -Drun_longhaul_tests=$run_longhaul_tests -Duse_amqp:BOOL=$build_amqp -Duse_http:BOOL=$build_http -Duse_mqtt:BOOL=$build_mqtt -Ddont_use_uploadtoblob:BOOL=$no_blob -Drun_unittests:BOOL=$run_unittests -Dno_logging:BOOL=$no_logging -Duse_prov_client:BOOL=$prov_auth -Duse_tpm_simulator:BOOL=$prov_use_tpm_simulator -Duse_edge_modules=$use_edge_modules -Dhsm_type_riot=$hsm_type_riot -Dhsm_type_x509=$hsm_type_x509 -Dhsm_type_symm_key=$hsm_type_symm_key -Dhsm_type_sastoken=$hsm_type_sastoken
chmod --recursive ugo+rw ../cmake

# Set the default cores
Expand Down
4 changes: 2 additions & 2 deletions build_all/linux/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ if [[ "$RUN_VALGRIND" == "run_valgrind" ]] ;
then
#use doctored openssl
export LD_LIBRARY_PATH=/usr/local/ssl/lib
ctest -j $TEST_CORES --output-on-failure --schedule-random
ctest -T test --no-compress-output -C "Debug" -V -j $TEST_CORES --schedule-random
export LD_LIBRARY_PATH=
else
ctest -j $TEST_CORES -C "Debug" --output-on-failure --schedule-random
ctest -T test --no-compress-output -C "Debug" -V -j $TEST_CORES --schedule-random
fi

6 changes: 6 additions & 0 deletions doc/run_end_to_end_tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ This document describes how to run the end to end tests.

Note: IOTHUB_E2E_X509_THUMBPRINT takes a string with HEX characters only; make sure all colons or spaces are removed from the thumbprint.

- Set the x509 certificate information for DPS:
- IOT_DPS_INDIVIDUAL_X509_CERTIFICATE
- IOT_DPS_INDIVIDUAL_X509_KEY
- IOT_DPS_INDIVIDUAL_REGISTRATION_ID

The certificate must have CN = <registration_id> and EKU set to the Client Authentication OID.

<a name="windows_client"></a>
## Run end to end tests on a Windows development environment
Expand Down
2 changes: 1 addition & 1 deletion iothub_client/devdoc/iothubclient_c_library.md
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ IoTHubDeviceClient_LL_SetOption(device_ll_handle, OPTION_OPENSSL_CIPHER_SUITE, "
```
- "Engine" - only available when OpenSSL is used. It specifies the [OpenSSL built-in engine](https://www.openssl.org/docs/man1.1.1/man3/ENGINE_load_builtin_engines.html) to be loaded. value is a null terminated string that contains the engine name.
- "x509PrivatekeyType" - only available when OpenSSL is used and OPENSSLOPT_ENGINE is configured. value is a pointer to a long. When set to 0x1, the private key is loaded from the OpenSSL Engine. The `x509privatekey` option represents the engine-specific certificate identifier.
- "x509PrivatekeyType" - only available when OpenSSL is used and OPTION_OPENSSL_ENGINE is configured. value is a pointer to a long. When set to 0x1, the private key is loaded from the OpenSSL Engine. The `x509privatekey` option represents the engine-specific certificate identifier.
### OpenSSL ENGINE Examples:
Expand Down
9 changes: 9 additions & 0 deletions iothub_client/inc/iothub_client_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,17 @@ extern "C"
static STATIC_VAR_UNUSED const char* OPTION_RETRY_MAX_DELAY_SECS = "retry_max_delay_secs";

static STATIC_VAR_UNUSED const char* OPTION_LOG_TRACE = "logtrace";

#ifndef OPTION_X509_CERT_DEF
#define OPTION_X509_CERT_DEF
static STATIC_VAR_UNUSED const char* OPTION_X509_CERT = "x509certificate";
#endif

#ifndef OPTION_X509_PRIVATE_KEY_DEF
#define OPTION_X509_PRIVATE_KEY_DEF
static STATIC_VAR_UNUSED const char* OPTION_X509_PRIVATE_KEY = "x509privatekey";
#endif

static STATIC_VAR_UNUSED const char* OPTION_KEEP_ALIVE = "keepalive";
static STATIC_VAR_UNUSED const char* OPTION_CONNECTION_TIMEOUT = "connect_timeout";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ and removing calls to _DoWork will yield the same results. */

/* Paste in the your x509 iothub connection string */
/* "HostName=<host_name>;DeviceId=<device_id>;x509=true" */
static const char* connectionString = "[device connection string]";
static const char* connectionString = "HostName=<host_name>;DeviceId=<device_id>;x509=true";

static const char* x509certificate =
"-----BEGIN CERTIFICATE-----""\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ TEST_SUITE_CLEANUP(TestClassCleanup)
dt_e2e_deinit();
}

#if 0 // TODO: #2238 - Fails Valgrind
TEST_FUNCTION(IoTHub_AMQP_SendReported_e2e_svc_fault_ctrl_kill_Tcp)
{
dt_e2e_send_reported_test_svc_fault_ctrl_kill_Tcp(AMQP_Protocol, IOTHUB_ACCOUNT_AUTH_CONNSTRING);
}
#endif

TEST_FUNCTION(IoTHub_AMQP_GetFullDesired_e2e_svc_fault_ctrl_kill_Tcp)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ TEST_SUITE_CLEANUP(TestClassCleanup)
dt_e2e_deinit();
}

#if 0 // TODO: #2238 - Fails Valgrind
TEST_FUNCTION(IoTHub_MQTT_SendReported_e2e_svc_fault_ctrl_kill_Tcp)
{
dt_e2e_send_reported_test_svc_fault_ctrl_kill_Tcp(MQTT_Protocol, IOTHUB_ACCOUNT_AUTH_CONNSTRING);
}
#endif

TEST_FUNCTION(IoTHub_MQTT_GetFullDesired_e2e_svc_fault_ctrl_kill_Tcp)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ if(LINUX AND ${use_openssl})
aziotsharedutil
)
endif()
else()
message(FATAL_ERROR "iothubclient_openssl_engine_e2e can only run on Linux with OpenSSL as the TLS stack.")
endif()
1 change: 1 addition & 0 deletions jenkins/linux_c_option_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ declare -a arr=(
"-Drun_e2e_tests=ON -Duse_azure_cloud_ecc_cert=ON"
"-Duse_prov_client:BOOL=ON -Dhsm_type_symm_key:BOOL=ON"
"-Duse_prov_client:BOOL=ON -Dhsm_type_x509:BOOL=ON"
"-Duse_prov_client:BOOL=ON -Dhsm_type_x509:BOOL=OFF -Dhsm_type_riot:BOOL=ON"
"-Duse_prov_client:BOOL=ON -Dhsm_type_sastoken:BOOL=ON"
)

Expand Down
18 changes: 17 additions & 1 deletion jenkins/linux_openssl_engine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ curl --version

# Set the default cores
CORES=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu)
cmake . -Bcmake -Duse_openssl:BOOL=ON -Drun_e2e_tests:BOOL=ON -Drun_e2e_openssl_engine_tests:BOOL=ON -Drun_valgrind:BOOL=ON
cmake . -Bcmake -Duse_openssl:BOOL=ON -Dhsm_type_x509:BOOL=ON -Duse_prov_client:BOOL=ON -Drun_e2e_tests:BOOL=ON -Drun_e2e_openssl_engine_tests:BOOL=ON -Drun_valgrind:BOOL=ON
cd cmake

make --jobs=$CORES

# Configure OpenSSL with PKCS#11 Engine and SoftHSM

## IoT Hub Tests:

# 1. Create new test token.
#softhsm2-util --delete-token --token test-token > /dev/null
softhsm2-util --init-token --slot 0 --label test-token --pin 1234 --so-pin 4321
Expand All @@ -31,3 +34,16 @@ softhsm2-util --pin 1234 --import ./test-key.p8 --token test-token --id b000 --l
rm test-key.pem
# 4. (Test) List keys associated with slot (should see the private key listed)
pkcs11-tool --module /usr/lib/softhsm/libsofthsm2.so -l -p 1234 --token test-token --list-objects


## Provisioning Tests:

# 2. Convert key from PKCS#1 to PKCS#8
echo $IOT_DPS_INDIVIDUAL_X509_KEY | base64 --decode > test-key.pem
openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in test-key.pem -out test-key.p8
# 3. Import private key into the token.
softhsm2-util --pin 1234 --import ./test-key.p8 --token test-token --id d000 --label dps-privkey
rm test-key.pem
# 4. (Test) List keys associated with slot (should see the private key listed)
pkcs11-tool --module /usr/lib/softhsm/libsofthsm2.so -l -p 1234 --token test-token --list-objects

2 changes: 1 addition & 1 deletion jenkins/osx_xcode_native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ rm -r -f $build_folder
mkdir -p $build_folder
pushd $build_folder

cmake .. -Drun_e2e_tests=ON -G Xcode -DCMAKE_BUILD_TYPE=Debug
cmake .. -Duse_prov_client=OFF -Dhsm_type_x509=OFF -Dhsm_type_sastoken=OFF -Dhsm_type_symm_key=OFF -Drun_e2e_tests=ON -G Xcode -DCMAKE_BUILD_TYPE=Debug
cmake --build . -- --jobs=$CORES
popd
2 changes: 1 addition & 1 deletion jenkins/ubuntu_c.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ build_root=$(cd "$(dirname "$0")/.." && pwd)
cd $build_root

# -- C --
./build_all/linux/build.sh --run-unittests --run_valgrind --run-e2e-tests --run-sfc-tests --provisioning --use-edge-modules "$@" #-x
./build_all/linux/build.sh --run-unittests --run_valgrind --run-e2e-tests --run-sfc-tests --provisioning --use-hsmsymmkey --use-hsmsas --use-hsmx509 --use-edge-modules "$@" #-x
[ $? -eq 0 ] || exit $?

22 changes: 22 additions & 0 deletions jenkins/ubuntu_c_riot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.

set -x # Set trace on
set -o errexit # Exit if command failed
set -o nounset # Exit if variable not set
set -o pipefail # Exit if pipe failed

# Print version
cat /etc/*release | grep VERSION*
gcc --version
openssl version
curl --version

build_root=$(cd "$(dirname "$0")/.." && pwd)
cd $build_root

# -- C --
./build_all/linux/build.sh --run-unittests --run_valgrind --run-e2e-tests --run-sfc-tests --provisioning --use-hsmsymmkey --use-hsmsas --use-hsmriot --use-edge-modules "$@" #-x
[ $? -eq 0 ] || exit $?

2 changes: 1 addition & 1 deletion jenkins/windows_c_vs2017.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ msbuild /m azure_iot_sdks.sln
if !ERRORLEVEL! neq 0 exit /b !ERRORLEVEL!

if %build-platform% neq arm (
ctest -C "debug" -V --schedule-random
ctest -T test --no-compress-output -C "Debug" -V --schedule-random
if not !ERRORLEVEL!==0 exit /b !ERRORLEVEL!
)

Expand Down
29 changes: 27 additions & 2 deletions provisioning_client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,19 @@ if (${hsm_type_custom})
set(HSM_CLIENT_LIBRARY ${CUSTOM_HSM_LIB})
elseif (${use_prov_client})
if (${run_e2e_tests})
# For e2e test we need to run a custom HSM to handle testing
# For e2e tests with riot, sastoken and tpm we need to run a custom HSM to handle testing
if (${hsm_type_x509})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHSM_TYPE_X509")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHSM_TYPE_X509")

set(HSM_CLIENT_H_FILES ${HSM_CLIENT_H_FILES}
${CMAKE_CURRENT_LIST_DIR}/adapters/hsm_client_x509.h)
set(HSM_CLIENT_C_FILES ${HSM_CLIENT_C_FILES}
${CMAKE_CURRENT_LIST_DIR}/adapters/hsm_client_x509.c)
endif()
if (${hsm_type_riot})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHSM_TYPE_RIOT")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHSM_TYPE_RIOT")
endif()
if (${hsm_type_sastoken})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHSM_TYPE_SAS_TOKEN")
Expand All @@ -65,7 +74,12 @@ elseif (${use_prov_client})
# For e2e test a custom HSM is needed
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/tests/common_prov_e2e/prov_hsm)

set(HSM_CLIENT_LIBRARY ${HSM_CLIENT_LIBRARY} msr_riot utpm prov_hsm)
if (${hsm_type_riot})
set(HSM_CLIENT_LIBRARY ${HSM_CLIENT_LIBRARY} msr_riot utpm prov_hsm)
else()
set(HSM_CLIENT_LIBRARY ${HSM_CLIENT_LIBRARY} utpm prov_hsm)
endif()

if (WIN32)
set(HSM_CLIENT_LIBRARY ${HSM_CLIENT_LIBRARY} Tbs)
endif ()
Expand All @@ -75,6 +89,17 @@ elseif (${use_prov_client})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHSM_TYPE_X509")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHSM_TYPE_X509")

set(HSM_CLIENT_H_FILES ${HSM_CLIENT_H_FILES}
${CMAKE_CURRENT_LIST_DIR}/adapters/hsm_client_x509.h)
set(HSM_CLIENT_C_FILES ${HSM_CLIENT_C_FILES}
${CMAKE_CURRENT_LIST_DIR}/adapters/hsm_client_x509.c)
endif()

if (${hsm_type_riot})
# Using RIoT
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHSM_TYPE_RIOT")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHSM_TYPE_RIOT")

set(HSM_CLIENT_H_FILES ${HSM_CLIENT_H_FILES}
${CMAKE_CURRENT_LIST_DIR}/adapters/hsm_client_riot.h)
set(HSM_CLIENT_C_FILES ${HSM_CLIENT_C_FILES}
Expand Down
8 changes: 6 additions & 2 deletions provisioning_client/adapters/hsm_client_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#endif

#if defined(HSM_TYPE_X509) || defined(HSM_AUTH_TYPE_CUSTOM)
#include "hsm_client_x509.h"
#endif

#if defined(HSM_TYPE_RIOT) || defined(HSM_AUTH_TYPE_CUSTOM)
#include "hsm_client_riot.h"
#endif

Expand All @@ -21,7 +25,7 @@
int initialize_hsm_system(void)
{
int result = 0;
#if defined(HSM_TYPE_X509) || defined(HSM_AUTH_TYPE_CUSTOM)
#if defined(HSM_TYPE_X509) || defined(HSM_TYPE_RIOT) || defined(HSM_AUTH_TYPE_CUSTOM)
// Initialize x509
if ((result == 0) && (hsm_client_x509_init() != 0))
{
Expand Down Expand Up @@ -52,7 +56,7 @@ void deinitialize_hsm_system(void)
#ifdef HSM_TYPE_HTTP_EDGE
hsm_client_http_edge_deinit();
#endif
#if defined(HSM_TYPE_X509) || defined(HSM_AUTH_TYPE_CUSTOM)
#if defined(HSM_TYPE_X509) || defined(HSM_TYPE_RIOT) || defined(HSM_AUTH_TYPE_CUSTOM)
hsm_client_x509_deinit();
#endif
#if defined(HSM_TYPE_SAS_TOKEN) || defined(HSM_AUTH_TYPE_CUSTOM)
Expand Down
2 changes: 1 addition & 1 deletion provisioning_client/adapters/hsm_client_riot.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ MOCKABLE_FUNCTION(, char*, hsm_client_riot_create_leaf_cert, HSM_CLIENT_HANDLE,
}
#endif /* __cplusplus */

#endif // HSM_CLIENT_RIOT
#endif // HSM_CLIENT_RIOT_H
Loading

0 comments on commit 1de399f

Please sign in to comment.