How to fix module identity authentication issue while IoTEdge device is registered via X509 self signed certificate

Vishnu Priya 5 Reputation points
2025-09-19T01:14:44.1933333+00:00

I have registered an edge device[gateway] to Azure IoTHub using x509 self signed certificate. The device got registered fine and modules [edgeAgent,edgeHub] got deployed along with some custom edge modules- with deployment status 200, device and modules status reporting. The modules are running on the edge device but the modules keep restarting as they couldnt authenticate.

 

edge Device registration is through x509 self signed certificate, with below properties in config.toml 

# Manual provisioning with x.509 certificates

[provisioning]

source = "manual"

iothub_hostname = "REQUIRED_IOTHUB_HOSTNAME"

device_id = "REQUIRED_DEVICE_ID_PROVISIONED_IN_IOTHUB"

[provisioning.authentication]

method = "x509"

identity_cert = "REQUIRED_URI_OR_POINTER_TO_DEVICE_IDENTITY_CERTIFICATE"

identity_pk = "REQUIRED_URI_TO_DEVICE_IDENTITY_PRIVATE_KEY"

 

Logs from edgeHub:

[INF] - Unable to authenticate client <deviceid>/<custom_edge_module> with cached service identity <deviceid>/<custom_edge_module> (Found: False). Resyncing service identity... <4> 2025-09-19 00:29:56.415 +00:00 [WRN] - Error while refreshing the service identity: <deviceid>/<custom_edge_module> OnBehalfOf: <deviceid> System.Collections.Generic.KeyNotFoundException: The given key '<deviceid>/<custom_edge_module>' was not present in the dictionary.    at Microsoft.Azure.Devices.Edge.Hub.Core.DeviceScopeIdentitiesCache.RefreshServiceIdentityInternal(String refreshTarget, String onBehalfOfDevice, Boolean invokeServiceIdentitiesUpdated) in /mnt/vss/_work/1/s/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Core/DeviceScopeIdentitiesCache.cs:line 187

 

device twin status:

  "deviceScope": "ms-azure-iot-edge://<devicescope>",
    "modelId": "",
    "status": "enabled",
    "statusUpdateTime": "0001-01-01T00:00:00.0000000Z",
    "lastActivityTime": "2025-09-19T00:47:10.0840495Z",
    "connectionState": "Connected",
    "cloudToDeviceMessageCount": 0,
    "authenticationType": "selfSigned",
    "x509Thumbprint": {
        "PrimaryThumbprint": "<thumbprint>"
    }

Module identity twin of edgeHub:

  "modelId": "",
    "status": "enabled",
    "statusUpdateTime": "0001-01-01T00:00:00.0000000Z",
    "lastActivityTime": "2025-09-19T00:42:23.4967322Z",
    "connectionState": "Connected",
    "cloudToDeviceMessageCount": 0,
    "authenticationType": "sas",
    "x509Thumbprint": {}

 

module identity twin of edgeAgent and other modules:

"modelId": "",
    "status": "enabled",
    "statusUpdateTime": "0001-01-01T00:00:00.0000000Z",
    "lastActivityTime": "2025-09-19T00:54:15.6085296Z",
    "connectionState": "Disconnected",
    "cloudToDeviceMessageCount": 0,
    "authenticationType": "sas",
    "x509Thumbprint": {}

The modules couldnt communicate to hub as they couldnt authenticate, where as the same modules works fine when the edge device is registered via shared access signature and send telemetry to iot hub.

 

Please let me know where could the issue be for modules not able to communicate with iotHub

Azure IoT Edge
Azure IoT Edge
An Azure service that is used to deploy cloud workloads to run on internet of things (IoT) edge devices via standard containers.
{count} votes

1 answer

Sort by: Most helpful
  1. Manas Mohanty 13,340 Reputation points Moderator
    2025-09-29T05:58:15.4533333+00:00

    Vishnu Priya

    Sorry for the delay in response

    Hyphens are allowed and below format is valide

    The device id contains alphabets [small and caps],numbers and hiphen

    Your device is using X.509 authentication, but the module identities (including edgeAgent and edgeHub) are showing sas as their authentication type in the twin properties.

    Fix:

    • Ensure that all modules are configured to use X.509 authentication if the device is using X.509.
    • Update the deployment manifest to explicitly set the authentication type for each module.

    Reference: https://github.com/Azure/iotedge/issues/7380

    If the issue persists even with x509 authentication (instead of SAS ) for module, Please share iot edge logs in private chat

    sudo iotedge check
    sudo iotedge system set-log-level debug
    sudo iotedge system logs -- -f
    

    Thank you

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.