nRF Connect: Azure IoT Hub: mqtt_helper: mqtt_connect, error: -22. native_sim board

Hi,

 I'm trying to run `ncs/v2.6.1/nrf/samples/net/azure_iot_hub` sample with `native_sim` board:

1. certificates are configured (compiled in)

2. `zeth` interface is running

3. application fails to connect, `mqtt_connect, error: -22`

The certificates should be valid, using `DigiCert Global Root G2`

*** Booting nRF Connect SDK v3.5.99-ncs1-1 ***
[00:00:00.000,000] <inf> net_config: Initializing network
[00:00:00.000,000] <inf> net_config: IPv4 address: 192.0.2.1
[00:00:00.000,000] <inf> azure_iot_hub_sample: Azure IoT Hub sample started
[00:00:00.000,000] <inf> azure_iot_hub_sample: Bringing network interface up and connecting to the network
[00:00:00.000,000] <inf> azure_iot_hub_sample: Device ID: TEST_DEVICE_007
[00:00:00.000,000] <inf> azure_iot_hub_sample: Network connectivity established and IP address assigned
[00:00:00.000,000] <inf> azure_iot_hub_sample: Connected to network
[00:00:00.000,000] <inf> azure_iot_hub_sample: Starting DPS
[00:00:00.000,000] <dbg> azure_iot_hub_dps: dps_reg_id_set: Setting DPS registration ID: TEST_DEVICE_007
[00:00:00.000,000] <dbg> azure_iot_hub_dps: dps_id_scope_set: No ID scope provided, using ID scope from Kconfig: <DPS_ID_RED>
[00:00:00.000,000] <dbg> azure_iot_hub_dps: dps_id_scope_set: Setting DPS ID scope: <DPS_ID_RED>
[00:00:00.000,000] <dbg> azure_iot_hub_dps: dps_on_settings_loaded: Settings fully loaded
[00:00:00.000,000] <dbg> azure_iot_hub_dps: dps_state_set: State transition: DPS_STATE_UNINIT --> DPS_STATE_DISCONNECTED
[00:00:00.000,000] <inf> azure_iot_hub_sample: DPS registration status: AZURE_IOT_HUB_DPS_REG_STATUS_NOT_STARTED
[00:00:00.000,000] <dbg> azure_iot_hub_dps: provisioning_client_init: Client ID (size: 21): TEST_DEVICE_007
[00:00:00.000,000] <dbg> azure_iot_hub_dps: provisioning_client_init: User name (size: 70): <DPS_ID_RED>/registrations/TEST_DEVICE_007/api-version=2019-03-31
[00:00:00.000,000] <dbg> mqtt_helper: mqtt_state_set: State transition: MQTT_STATE_UNINIT --> MQTT_STATE_DISCONNECTED
[00:00:00.000,000] <dbg> mqtt_helper: broker_init: Resolving IP address for global.azure-devices-provisioning.net
DBG_PRINTF: [ncs/v2.6.1/zephyr/subsys/net/lib/mqtt/mqtt_transport_socket_tls.c:117]: mqtt_client_tls_connect err: -1
[00:00:00.000,000] <dbg> mqtt_helper: mqtt_helper_poll_loop: Waiting for connection_poll_sem
[00:00:00.720,000] <dbg> mqtt_helper: broker_init: IPv4 Address found 20.50.65.141 (AF_INET)
[00:00:00.720,000] <dbg> mqtt_helper: mqtt_state_set: State transition: MQTT_STATE_DISCONNECTED --> MQTT_STATE_TRANSPORT_CONNECTING
[00:00:00.720,000] <dbg> net_mqtt_sock_tls: mqtt_client_tls_connect: (0x80c4300): Created socket 0
[00:00:00.780,000] <err> mqtt_helper: mqtt_connect, error: -22
[00:00:00.780,000] <dbg> mqtt_helper: mqtt_state_set: State transition: MQTT_STATE_TRANSPORT_CONNECTING --> MQTT_STATE_DISCONNECTED
[00:00:00.780,000] <err> azure_iot_hub_dps: mqtt_helper_connect failed, error: -22
[00:00:00.780,000] <err> azure_iot_hub_sample: DPS failed to start, error: -22
[00:00:00.780,000] <err> azure_iot_hub_sample: Failed to run DPS, error: -22, terminating connection attempt

Log `*_RED` fields are edited.

Is there any way to debug this to understand where the problem might be?

Any help is appreciated. Regards.

  • Hi Michal,

      I'm not able to debug where the problem might be, so nothing changed.

      I've got no updates to report from my side. (I have a suspicion that the algorithm I'm using is not supported and/or key format is somehow not recognized, but I've got no [known] way to verify this hypothesis).

    Regards.

  • Could you upload the certificate that you are using, just so I could check it myself?

    Best regards,

    Michal

  • Hi Michal,

     I'm afraid I cannot do this since these keys cannot be shared especially in a public ticket.

     However, if there is no other way and you insist on this, we need to consider making this ticket private first.

    Best regards.

  • I thought you were using the DigiCert Global Root G2 certificate that is public? Or are there any other certificates as well, that are your own private ones?

  • Hi Michal,

     I mean these files: ca-cert.pem (DigiCert Global Root G2 certificate), client-cert.pem, private-key.pem

    The "DigiCert Global Root G2 certificate" content (copied from [1]) is the following:

    /* DigiCert Global Root G2 */
    "-----BEGIN CERTIFICATE-----\r\n"
    "MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBh\r\n"
    "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\r\n"
    "d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBH\r\n"
    "MjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAwMDBaMGExCzAJBgNVBAYTAlVT\r\n"
    "MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\r\n"
    "b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEcyMIIBIjANBgkqhkiG\r\n"
    "9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzfNNNx7a8myaJCtSnX/RrohCgiN9RlUyfuI\r\n"
    "2/Ou8jqJkTx65qsGGmvPrC3oXgkkRLpimn7Wo6h+4FR1IAWsULecYxpsMNzaHxmx\r\n"
    "1x7e/dfgy5SDN67sH0NO3Xss0r0upS/kqbitOtSZpLYl6ZtrAGCSYP9PIUkY92eQ\r\n"
    "q2EGnI/yuum06ZIya7XzV+hdG82MHauVBJVJ8zUtluNJbd134/tJS7SsVQepj5Wz\r\n"
    "tCO7TG1F8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyMUNGPHgm+F6HmIcr9g+UQ\r\n"
    "vIOlCsRnKPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQABo0IwQDAP\r\n"
    "BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV\r\n"
    "5uNu5g/6+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY\r\n"
    "1Yl9PMWLSn/pvtsrF9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4\r\n"
    "NeF22d+mQrvHRAiGfzZ0JFrabA0UWTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NG\r\n"
    "Fdtom/DzMNU+MeKNhJ7jitralj41E6Vf8PlwUHBHQRFXGU7Aj64GxJUTFy8bJZ91\r\n"
    "8rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/iyK5S9kJRaTe\r\n"
    "pLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl\r\n"
    "MrY=\r\n"
    "-----END CERTIFICATE-----\r\n"
    

    I hope this helps.

    References:

    [1]: github.com/.../certs.c

    Best regards

Related