0
votes

I am using the C Azure IoT SDK on my device to communicate with my Azure IoT hub via MQTT.

Using symmetric key authentication, everything works perfectly. I can create a device on the hub, copy the connection string to my device application code, and all good.

However, I wish to use X.509 certificates for authentication instead as it's more secure. It's possible to select self-signed or CA-signed options when creating a device on the hub. The connection string does not get generated then.

The example device application code which comes with the Azure IoT C SDK however always uses the following function when creating a device handle, even in the iothub_ll_client_x509_sample.c :

IoTHubDeviceClient_LL_CreateFromConnectionString(connectionString, protocol);

This will not work when using X.509 authentication methods as there isn't any connection string.

Does anyone know how I can progress with this problem? How to connect ? There is lots of information regarding registering certificates on the hub etc. , but not on how to connect using the C SDK.

1

1 Answers

2
votes

the sample code you're looking at should show you how to use an X.509 certificate. The connection string (see line 55) looks like:

"HostName=<host_name>;DeviceId=<device_id>;x509=true" 

The sample also shows you how to include the X.509 certificate and key.