question

Pavan-7619 avatar image
0 Votes"
Pavan-7619 asked asergaz answered

running the prov_dev_client_sample outside of the repo with custom hsm compiled

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

azure-iot-hubazure-iot-sdkazure-iot-dps
· 9
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @Pavan-7619 ,
Thank you for your question and welcome to Microsoft Q&A!

Can you confirm that you have followed the steps as described here?: https://github.com/Azure/azure-iot-sdk-c/blob/master/provisioning_client/devdoc/using_provisioning_client.md#enabling-provisioning-device-client

Thanks!




0 Votes 0 ·

Hey @asergaz , I can definitely confirm that I followed all the steps in that enabling provision device client and also the custom hsm part as I've mentioned.

1 Vote 1 ·

I suspect some configuration needs to be done on cmake. You are trying to port the SDK to a new platform?

https://github.com/Azure/azure-iot-sdk-c#compile-the-sdk

37155-image.png


0 Votes 0 ·
image.png (53.7 KiB)
Show more comments

1 Answer

asergaz avatar image
0 Votes"
asergaz answered

Hello @Pavan-7619 ,

As per the related issue on github:

"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. The custom hsm would have to be named something else and likely added to the CMake list."

https://github.com/Azure/azure-iot-sdk-c/issues/1725

49475-image.png

Thank you so much for your time and in the hope to help others facing the same issue can you please mark this as answer?

Remember:
- Please accept an answer if correct. Original posters help the community find answers faster by identifying the correct answer. Here is how.






image.png (124.3 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.