espressif/esp-azure

prov_dev_client_ll_sample - Failure encountered on registration PROV_DEVICE_RESULT_DEV_AUTH_ERROR (CA-279)

Closed this issue · 1 comments

Hello,

I'm setting up a DPS for an ESP32. I've followed all the steps in the README file of the example prov_dev_client_ll_sample (and triple checked if I did everything correctly).

However I'm getting the following error:

Error: Time:Tue Feb 28 16:34:58 2023 File:/path_to_esp_azure/esp-azure/azure-iot-sdk-c/provisioning_client/src/prov_transport_mqtt_common.c Func:mqtt_operation_complete_callback Line:205 Connection Not Accepted: 0x5: Not Authorized
Error: Time:Tue Feb 28 16:34:58 2023 File:/path_to_esp_azure/esp-azure/azure-iot-sdk-c/provisioning_client/src/prov_device_ll_client.c Func:on_transport_registration_data Line:572 Failure retrieving data from the provisioning service
Failure encountered on registration PROV_DEVICE_RESULT_DEV_AUTH_ERROR
registration failed!

My certificate files do not contain any capital letters or special characters, as was mentioned in previous issues. However I did notice that the SNTP sync was off by one hour. I've tried to manually add another hour to the time received from the SNTP sync. This did not solve my connection problem mentioned above. I did check if the time was set correctly after my adjustments with the following code (my timezone is CET):

    time_t now;
    char strftime_buf[64];
    struct tm timeinfo;

    time(&now);
    setenv("TZ", "CET", 1);
    tzset();

    localtime_r(&now, &timeinfo);
    strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
    printf("The current date/time is: %s\n\n", strftime_buf);

Since the output of this print statement is correct, I assume my time is set correctly on the ESP32 and should not affect the connection to iothub, is this correct? If not, how should i adjust the sntp in esp-azure to set my timezone correctly? I've already tried changing the NTP server to multiple different things, but the time does not change.

If my time is set correctly on the ESP32, what else can I check that might affect a correct implementation of this example?

When enabling the trace_on option, i get a lot of 'handshake in progress...' logs followed by this error:

-> 16:34:58 CONNECT | VER: 4 | KEEPALIVE: 0 | FLAGS: 130 | USERNAME: XXX/registrations/jorunprovtest/api-version=2018-09-01-preview&ClientVersion=1.2.14 | CLEAN: 1
<- 16:34:58 CONNACK | SESSION_PRESENT: false | RETURN_CODE: 0x5

My issue was solved by changing the connection string in menuconfig to the correct string.

Above I used the string of the IoThub linked to the DPS, but the DPS connection string should be used instead.