Search code examples
cazure-iot-hubazure-iot-sdk

Errors and seg fault when using device provisioning service


I am trying to use the device provisioning service from my device to connect to the hub, using the c SDK. I am using individual enrollment and X.509. I created an individual enrollment on the hub using a certificate I generated using the "dice_device_enrollment" tool of the SDK. I also installed the certificate on the device. When I run the code I get (OpenSSL) errors when executing the Prov_Device_LL_DoWork() function. When I call Prov_Device_LL_DoWork() the second time, the program seg faults.

Output:

08:11:25 10-10-2018  [info] Prov_Device_LL_DoWork
Error: Time:Wed Oct 10 08:11:25 2018 File:/home/tijmen/azure-iot-sdk-c/c-utility/adapters/x509_openssl.c Func:log_ERR_get_error Line:29 Failure creating private key evp_key
Error: Time:Wed Oct 10 08:11:25 2018 File:/home/tijmen/azure-iot-sdk-c/c-utility/adapters/x509_openssl.c Func:log_ERR_get_error Line:36   [0] error:0906D06C:PEM routines:PEM_read_bio:no start line
Error: Time:Wed Oct 10 08:11:25 2018 File:/home/tijmen/azure-iot-sdk-c/c-utility/adapters/x509_openssl.c Func:log_ERR_get_error Line:36   [1] error:0906D064:PEM routines:PEM_read_bio:bad base64 decode
Error: Time:Wed Oct 10 08:11:25 2018 File:/home/tijmen/azure-iot-sdk-c/c-utility/adapters/tlsio_openssl.c Func:log_ERR_get_error Line:428 unable to use x509 authentication
Error: Time:Wed Oct 10 08:11:25 2018 File:/home/tijmen/azure-iot-sdk-c/c-utility/adapters/tlsio_openssl.c Func:tlsio_openssl_open Line:1251 Failed creating the OpenSSL instance.
Error: Time:Wed Oct 10 08:11:25 2018 File:/home/tijmen/azure-iot-sdk-c/umqtt/src/mqtt_client.c Func:mqtt_client_connect Line:1000 Error: io_open failed
Error: Time:Wed Oct 10 08:11:25 2018 File:/home/tijmen/azure-iot-sdk-c/provisioning_client/src/prov_transport_mqtt_common.c Func:create_connection Line:567 Failure connecting to mqtt server
Error: Time:Wed Oct 10 08:11:25 2018 File:/home/tijmen/azure-iot-sdk-c/provisioning_client/src/prov_transport_mqtt_common.c Func:prov_transport_common_mqtt_dowork Line:874 unable to create amqp connection
08:11:25 10-10-2018  [info] Prov_Device_LL_DoWork
Segmentation fault

The same code does work on my dev machine, but using slightly different version of OpenSSL: On the dev machine OpenSSL 1.0.1t 3 May 2016 On the device OpenSSL 1.0.2d 9 Jul 2015

Are there requirements on the OpenSSL version I missed?


Solution

  • It turns out that upgrading OpenSSL solves this problem. I built OpenSSL version 1.0.2q from https://github.com/openssl/openssl/tree/OpenSSL_1_0_2-stable and linked it to my app. This solved the error. It seems the SDK, at least X.509 functionality requires an higher version of OpenSSL than 1.0.2d 9 Jul 2015.