Reputation: 1
I have been trying to find a way to send telemetry messages from iot hub device to cloud using a REST API. I could achieve this using a SaS device easily. I would like to know the way to send messages by feeding x509 certificate and key of the device in curl request.
Does anyone has a solution to this?
I have used the following curl request to perform the same: curl -L -i -X POST https://myHub.azure-devices.net/devices/myDeviceId/messages/events?api-version=2020-03-13 -cert ./clientcert.pem –key ./privatekey.pem -H 'Content-Type: application/json' -H 'Content-Encoding: utf-8' -d '{"temperature": 30}'
But, it results in the below error: HTTP/1.1 401 Unauthorized Content-Length: 161 Content-Type: application/json; charset=utf-8 Server: Microsoft-HTTPAPI/2.0 x-ms-request-id: 07929d22-f0a2-4ec6-9ca8-473ed35a5151 iothub-errorcode: IotHubUnauthorizedAccess Date: Mon, 21 Nov 2022 10:22:27 GMT
{"Message":"ErrorCode:IotHubUnauthorizedAccess;Unauthorized","ExceptionMessage":"Tracking ID:07929d22f0a24ec69ca8473ed35a5151-G:0-TimeStamp:11/21/2022 10:22:27"}curl: (6) Could not resolve host: curl: (3) Failed to convert –key to ACE; string contains a disallowed character
curl: (6) Could not resolve host:
Upvotes: 0
Views: 318
Reputation: 653
Authentication with an Azure IoT hub using X.509 via REST is not currently supported. However, you may be able to test this functionality in preview mode: https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-x509ca-concept
Upvotes: 0