So, following the docs, I am able to compile a custom HSM lib and link it to the sdk, and doing that, if I run the sample provided in prov_dev_client_sample with the certs in the same cmake directory (i.e azure-iot-sdk-c/cmake/*). But I created a new project and wanted to use the sample to start off and i get no errors in compiling, but when I run the code out of the repo. it gives me the below error
Error: Time:Fri Oct 30 11:19:56 2020 File:/build/azure-iot-sdk-c-aYsk0M/azure-iot-sdk-c-0.2.0.0/provisioning_client/src/prov_security_factory.c Func:prov_dev_security_init Line:63 HSM type 2 is not supported on this SDK build
Provisioning API Version: 1.3.9
Error: Time:Fri Oct 30 11:19:56 2020 File:/build/azure-iot-sdk-c-aYsk0M/azure-iot-sdk-c-0.2.0.0/provisioning_client/src/prov_auth_client.c Func:prov_auth_create Line:298 hsm_client_create is not a valid address
Error: Time:Fri Oct 30 11:19:56 2020 File:/home/peekay/playground/azure-iot-sdk-c/provisioning_client/src/prov_device_ll_client.c Func:Prov_Device_LL_Create Line:897 failed calling prov_auth_create
Error: Time:Fri Oct 30 11:19:56 2020 File:/home/peekay/playground/azure-iot-sdk-c/provisioning_client/src/prov_device_client.c Func:Prov_Device_Create Line:124 Prov_Device_LL_Create failed
failed calling Prov_Device_Create
Press enter key to exit:
This is my corresponding cmake file
cmake_minimum_required(VERSION 3.16)
project(reader_simulation_azure C)
set(CMAKE_C_STANDARD 99)
set(AZUREIOT_INC_FOLDER ".." "." "./deps/parson" "/usr/local/include/azureiot" "/usr/local/include/azureiot/inc")
include_directories(${AZUREIOT_INC_FOLDER})
add_executable(reader_simulation_azure main.c)
target_link_libraries(reader_simulation_azure
uuid
prov_mqtt_transport
prov_device_client
prov_device_ll_client
prov_auth_client
hsm_security_client
uhttp
iothub_client
iothub_client_mqtt_transport
umqtt
aziotsharedutil
ssl
pthread
curl
ssl
crypto
m
parson
)
upon checking I see that the Cmake file in the repo has the cmake flags needed to enable these and my code does not. any help as to what needs to change and what is going wrong would mean a lot.
Thanks in advance
Same question on Microsoft Q&A: https://docs.microsoft.com/en-us/answers/questions/145389/index.html
@asergaz yes I asked the same there too! Yet to receive a reply
@impeekay thanks! I have cross-referenced both. I will follow-up with you in Microsoft Q&A and if we find this is a bug or needs further troubleshooting we can continue the discussion here. Thanks.
@asergaz that'd be great, thanks!
Hi @Impeekay thanks for the patience.
So this all look like runtime errors, as you pointed out. If everything is compiling just fine, this leads me to believe that your custom hsm isn't set up correctly. Are you coding it up yourself or are you using the custom example in the SDK?
@danewalton thanks for the reply, yes I am using the example given.
So are you looking to have the options enabled at your CMake level? If so, you can set CMake variables in your CMake to cache to propagate to our SDK. Example:
set(hsm_type_custom "your path thing here" CACHE STRING "My HSM Path" FORCE)
@danewalton i think I did that during the compilation of the sdk, but the issue is using the sdk and then running the example out of the example folder, which is the regular use case and I got the runtime errors.
Okay so is the CMake above the exact one you are using to compile? If so, which of the library targets is your compiled hsm? In this list:
target_link_libraries(reader_simulation_azure
uuid
prov_mqtt_transport
prov_device_client
prov_device_ll_client
prov_auth_client
hsm_security_client
uhttp
iothub_client
iothub_client_mqtt_transport
umqtt
aziotsharedutil
ssl
pthread
curl
ssl
crypto
m
parson
)
I don't see a lib for custom hsm code.
Hi @Impeekay please let us know which of the library targets is your compiled hsm so we can continue the troubleshooting. Thank you!
Hello @Impeekay I kind request your follow-up or please let us know if you are no longer blocked?
Thank you!
hey @asergaz sorry for the late reply, the custom hsm that I've compiled is hsm_security_client. Also, I moved the project to python, that is the reason I've been unresponsive here, But if you need help resolving this, I can help you out. Let me know.
If you named your custom hsm implementation hsm_security_client then you would run into an issue of name clashing with another lib we have named the same thing:
https://github.com/Azure/azure-iot-sdk-c/blob/c219a67171dad809a73f98f346248d448da73e53/provisioning_client/CMakeLists.txt#L185
The custom hsm would have to be named something else and likely added to the CMake list. I will go ahead and close the issue for now but feel free to add a comment here if you would like to follow up.
@Impeekay, @danewalton, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey