iotedge: TLS handshake failed., System.IO.IOException

Expected Behavior

Module sending data to iothub.

Current Behavior

Getting TLS handshake errors between the edgeHub and a custom C# module when trying to connect to the mqqt.

Output of iotedge check

Click here

Configuration checks (aziot-identity-service)
---------------------------------------------
√ keyd configuration is well-formed - OK
√ certd configuration is well-formed - OK
√ tpmd configuration is well-formed - OK
√ identityd configuration is well-formed - OK
√ daemon configurations up-to-date with config.toml - OK
√ identityd config toml file specifies a valid hostname - OK
√ aziot-identity-service package is up-to-date - OK
√ host time is close to reference time - OK
√ preloaded certificates are valid - OK
√ keyd is running - OK
√ certd is running - OK
√ identityd is running - OK
√ read all preloaded certificates from the Certificates Service - OK
√ read all preloaded key pairs from the Keys Service - OK
√ check all EST server URLs utilize HTTPS - OK
√ ensure all preloaded certificates match preloaded private keys with the same ID - OK

Connectivity checks (aziot-identity-service)
--------------------------------------------
√ host can connect to and perform TLS handshake with iothub AMQP port - OK
√ host can connect to and perform TLS handshake with iothub HTTPS / WebSockets port - OK
√ host can connect to and perform TLS handshake with iothub MQTT port - OK

Configuration checks
--------------------
√ aziot-edged configuration is well-formed - OK
√ configuration up-to-date with config.toml - OK
√ container engine is installed and functional - OK
√ configuration has correct URIs for daemon mgmt endpoint - OK
√ aziot-edge package is up-to-date - OK
√ container time is close to host time - OK
‼ DNS server - Warning
    Container engine is not configured with DNS server setting, which may impact connectivity to IoT Hub.
    Please see https://aka.ms/iotedge-prod-checklist-dns for best practices.
    You can ignore this warning if you are setting DNS server per module in the Edge deployment.
‼ production readiness: logs policy - Warning
    Container engine is not configured to rotate module logs which may cause it run out of disk space.
    Please see https://aka.ms/iotedge-prod-checklist-logs for best practices.
    You can ignore this warning if you are setting log policy per module in the Edge deployment.
‼ production readiness: Edge Agent's storage directory is persisted on the host filesystem - Warning
    The edgeAgent module is not configured to persist its /tmp/edgeAgent directory on the host filesystem.
    Data might be lost if the module is deleted or updated.
    Please see https://aka.ms/iotedge-storage-host for best practices.
‼ production readiness: Edge Hub's storage directory is persisted on the host filesystem - Warning
    The edgeHub module is not configured to persist its /tmp/edgeHub directory on the host filesystem.
    Data might be lost if the module is deleted or updated.
    Please see https://aka.ms/iotedge-storage-host for best practices.
√ Agent image is valid and can be pulled from upstream - OK
√ proxy settings are consistent in aziot-edged, aziot-identityd, moby daemon and config.toml - OK

Connectivity checks
-------------------
√ container on the default network can connect to upstream AMQP port - OK
√ container on the default network can connect to upstream HTTPS / WebSockets port - OK
√ container on the IoT Edge module network can connect to upstream AMQP port - OK
√ container on the IoT Edge module network can connect to upstream HTTPS / WebSockets port - OK
31 check(s) succeeded.
4 check(s) raised warnings. Re-run with --verbose for more details.
2 check(s) were skipped due to errors from other checks. Re-run with --verbose for more details.

Device Information

  • Host OS: Ubuntu 22.04
  • Architecture: amd64
  • Container OS: Docker

Runtime Versions

  • aziot-edged: iotedge 1.4.27
  • Edge Agent: 1.4
  • Edge Hub: 1.4
  • Docker/Moby: 24.0.7-1

Logs

logs from the module:

[08:39:57 WRN] Connection changed: Status: Disconnected_Retrying Reason: Communication_Error
[08:39:57 WRN] Connection changed: Status: Disconnected Reason: Retry_Expired
aziot-edged logs

Partially omitted due to github content length. This part contains the only visible error.

jan 10 09:33:38 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:33:38Z [INFO] - Watchdog checking Edge runtime status
jan 10 09:33:38 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:33:38Z [INFO] - Edge runtime is running
jan 10 09:33:39 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:33:39Z [INFO] - <-- GET /modules?api-version=2022-08-03 {"accept": "application/json", "host": "mgmt.sock:80", "connection": "close"}
jan 10 09:33:39 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:33:39Z [INFO] - --> 200 {"content-type": "application/json"}
jan 10 09:33:44 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:33:44Z [INFO] - <-- GET /modules?api-version=2022-08-03 {"accept": "application/json", "host": "mgmt.sock:80", "connection": "close"}
jan 10 09:33:44 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:33:44Z [INFO] - --> 200 {"content-type": "application/json"}
jan 10 09:33:49 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:33:49Z [INFO] - <-- GET /modules?api-version=2022-08-03 {"accept": "application/json", "host": "mgmt.sock:80", "connection": "close"}
jan 10 09:33:49 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:33:49Z [INFO] - --> 200 {"content-type": "application/json"}
jan 10 09:33:54 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:33:54Z [INFO] - <-- GET /modules?api-version=2022-08-03 {"accept": "application/json", "host": "mgmt.sock:80", "connection": "close"}
jan 10 09:33:54 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:33:54Z [INFO] - --> 200 {"content-type": "application/json"}
jan 10 09:33:59 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:33:59Z [INFO] - <-- GET /modules?api-version=2022-08-03 {"accept": "application/json", "host": "mgmt.sock:80", "connection": "close"}
jan 10 09:33:59 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:33:59Z [INFO] - --> 200 {"content-type": "application/json"}
jan 10 09:34:04 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:34:04Z [INFO] - <-- GET /modules?api-version=2022-08-03 {"accept": "application/json", "host": "mgmt.sock:80", "connection": "close"}
jan 10 09:34:04 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:34:04Z [INFO] - --> 200 {"content-type": "application/json"}
jan 10 09:34:09 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:34:09Z [INFO] - <-- GET /modules?api-version=2022-08-03 {"accept": "application/json", "host": "mgmt.sock:80", "connection": "close"}
jan 10 09:34:09 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:34:09Z [INFO] - --> 200 {"content-type": "application/json"}
jan 10 09:34:14 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:34:14Z [INFO] - <-- GET /modules?api-version=2022-08-03 {"accept": "application/json", "host": "mgmt.sock:80", "connection": "close"}
jan 10 09:34:14 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:34:14Z [INFO] - --> 200 {"content-type": "application/json"}
jan 10 09:34:19 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:34:19Z [INFO] - <-- GET /modules?api-version=2022-08-03 {"accept": "application/json", "host": "mgmt.sock:80", "connection": "close"}
jan 10 09:34:19 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:34:19Z [INFO] - --> 200 {"content-type": "application/json"}
jan 10 09:34:21 dev-Virtual-Machine aziot-certd[31454]: 2024-01-10T08:34:21Z [INFO] - <-- GET /certificates/aziot-edged-trust-bundle?api-version=2020-09-01 {"host": "certd.sock"}
jan 10 09:34:21 dev-Virtual-Machine aziot-certd[31454]: 2024-01-10T08:34:21Z [INFO] - --> 200 {"content-type": "application/json"}
jan 10 09:34:21 dev-Virtual-Machine aziot-keyd[31397]: 2024-01-10T08:34:21Z [INFO] - <-- GET /keypair/device-id?api-version=2021-05-01 {"host": "keyd.sock"}
jan 10 09:34:21 dev-Virtual-Machine aziot-keyd[31397]: 2024-01-10T08:34:21Z [ERR!] - error:1E08010C:DECODER routines:OSSL_DECODER_from_bio:unsupported:../crypto/encode_decode/decoder_lib.c:101:No supported data to decode. Input type: PEM
jan 10 09:34:21 dev-Virtual-Machine aziot-keyd[31397]: 2024-01-10T08:34:21Z [ERR!] - !!! internal error
jan 10 09:34:21 dev-Virtual-Machine aziot-keyd[31397]: 2024-01-10T08:34:21Z [ERR!] - !!! caused by: could not load key pair
jan 10 09:34:21 dev-Virtual-Machine aziot-keyd[31397]: 2024-01-10T08:34:21Z [ERR!] - !!! caused by: could not load key pair: AZIOT_KEYS_RC_ERR_EXTERNAL
jan 10 09:34:21 dev-Virtual-Machine aziot-keyd[31397]: 2024-01-10T08:34:21Z [INFO] - --> 500 {"content-type": "application/json"}
jan 10 09:34:24 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:34:24Z [INFO] - <-- GET /modules?api-version=2022-08-03 {"accept": "application/json", "host": "mgmt.sock:80", "connection": "close"}
jan 10 09:34:24 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:34:24Z [INFO] - --> 200 {"content-type": "application/json"}
jan 10 09:34:24 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:34:24Z [INFO] - <-- GET /modules/?api-version=2018-06-28 {"host": "unix:///var/run/iotedge/mgmt.sock", "connection": "Close"}
jan 10 09:34:24 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:34:24Z [INFO] - --> 200 {"content-type": "application/json"}
jan 10 09:34:29 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:34:29Z [INFO] - <-- GET /modules?api-version=2022-08-03 {"accept": "application/json", "host": "mgmt.sock:80", "connection": "close"}
jan 10 09:34:29 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:34:29Z [INFO] - --> 200 {"content-type": "application/json"}
jan 10 09:34:34 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:34:34Z [INFO] - <-- GET /modules?api-version=2022-08-03 {"accept": "application/json", "host": "mgmt.sock:80", "connection": "close"}
jan 10 09:34:34 dev-Virtual-Machine aziot-edged[31393]: 2024-01-10T08:34:34Z [INFO] - --> 200 {"content-type": "application/json"}
edge-agent logs

<6> 2024-01-10 08:28:16.216 +00:00 [INF] - Received direct method call - ping
<6> 2024-01-10 08:28:16.216 +00:00 [INF] - Received request ping with payload
<6> 2024-01-10 08:28:16.216 +00:00 [INF] - Successfully handled request ping
<6> 2024-01-10 08:28:16.511 +00:00 [INF] - Received direct method call - GetModuleLogs
<6> 2024-01-10 08:28:16.512 +00:00 [INF] - Received request GetModuleLogs with payload
<6> 2024-01-10 08:28:16.512 +00:00 [INF] - Processing request to get logs for {"schemaVersion":"1.0","items":{"id":"\\bModBusModule\\b","filter":{"tail":1500,"since":"15m","until":null,"loglevel":null,"regex":""}},"encoding":1,"contentType":1}
<6> 2024-01-10 08:28:16.519 +00:00 [INF] - Initiating streaming logs for ModBusModule
<6> 2024-01-10 08:28:16.561 +00:00 [INF] - Received 1861 bytes of logs for ModBusModule
<6> 2024-01-10 08:28:16.561 +00:00 [INF] - Successfully handled request GetModuleLogs
<6> 2024-01-10 08:28:31.700 +00:00 [INF] - Received direct method call - ping
<6> 2024-01-10 08:28:31.701 +00:00 [INF] - Received request ping with payload
<6> 2024-01-10 08:28:31.701 +00:00 [INF] - Successfully handled request ping
<6> 2024-01-10 08:28:31.788 +00:00 [INF] - Received direct method call - GetModuleLogs
<6> 2024-01-10 08:28:31.789 +00:00 [INF] - Received request GetModuleLogs with payload
<6> 2024-01-10 08:28:31.789 +00:00 [INF] - Processing request to get logs for {"schemaVersion":"1.0","items":{"id":"\\bedgeHub\\b","filter":{"tail":1500,"since":"15m","until":null,"loglevel":null,"regex":""}},"encoding":1,"contentType":1}
<6> 2024-01-10 08:28:31.795 +00:00 [INF] - Initiating streaming logs for edgeHub
<6> 2024-01-10 08:28:31.796 +00:00 [INF] - Received 437 bytes of logs for edgeHub
<6> 2024-01-10 08:28:31.797 +00:00 [INF] - Successfully handled request GetModuleLogs
<6> 2024-01-10 08:30:18.988 +00:00 [INF] - Received direct method call - ping
<6> 2024-01-10 08:30:18.989 +00:00 [INF] - Received request ping with payload
<6> 2024-01-10 08:30:18.989 +00:00 [INF] - Successfully handled request ping
<6> 2024-01-10 08:30:19.065 +00:00 [INF] - Received direct method call - GetModuleLogs
<6> 2024-01-10 08:30:19.066 +00:00 [INF] - Received request GetModuleLogs with payload
<6> 2024-01-10 08:30:19.066 +00:00 [INF] - Processing request to get logs for {"schemaVersion":"1.0","items":{"id":"\\bModBusModule\\b","filter":{"tail":1500,"since":"15m","until":null,"loglevel":null,"regex":""}},"encoding":1,"contentType":1}
<6> 2024-01-10 08:30:19.073 +00:00 [INF] - Initiating streaming logs for ModBusModule
<6> 2024-01-10 08:30:19.142 +00:00 [INF] - Received 2003 bytes of logs for ModBusModule
<6> 2024-01-10 08:30:19.143 +00:00 [INF] - Successfully handled request GetModuleLogs
<6> 2024-01-10 08:35:26.892 +00:00 [INF] - Received direct method call - ping
<6> 2024-01-10 08:35:26.892 +00:00 [INF] - Received request ping with payload
<6> 2024-01-10 08:35:26.893 +00:00 [INF] - Successfully handled request ping
<6> 2024-01-10 08:35:26.984 +00:00 [INF] - Received direct method call - GetModuleLogs
<6> 2024-01-10 08:35:26.984 +00:00 [INF] - Received request GetModuleLogs with payload
<6> 2024-01-10 08:35:26.984 +00:00 [INF] - Processing request to get logs for {"schemaVersion":"1.0","items":{"id":"\\bedgeHub\\b","filter":{"tail":1500,"since":"15m","until":null,"loglevel":null,"regex":""}},"encoding":1,"contentType":1}
<6> 2024-01-10 08:35:26.989 +00:00 [INF] - Initiating streaming logs for edgeHub
<6> 2024-01-10 08:35:26.990 +00:00 [INF] - Received 586 bytes of logs for edgeHub
<6> 2024-01-10 08:35:26.991 +00:00 [INF] - Successfully handled request GetModuleLogs
<6> 2024-01-10 08:35:37.165 +00:00 [INF] - Received direct method call - ping
<6> 2024-01-10 08:35:37.166 +00:00 [INF] - Received request ping with payload
<6> 2024-01-10 08:35:37.166 +00:00 [INF] - Successfully handled request ping
<6> 2024-01-10 08:35:37.237 +00:00 [INF] - Received direct method call - GetModuleLogs
<6> 2024-01-10 08:35:37.237 +00:00 [INF] - Received request GetModuleLogs with payload
<6> 2024-01-10 08:35:37.237 +00:00 [INF] - Processing request to get logs for {"schemaVersion":"1.0","items":{"id":"\\bModBusModule\\b","filter":{"tail":1500,"since":"15m","until":null,"loglevel":null,"regex":""}},"encoding":1,"contentType":1}
<6> 2024-01-10 08:35:37.244 +00:00 [INF] - Initiating streaming logs for ModBusModule
<6> 2024-01-10 08:35:37.319 +00:00 [INF] - Received 1991 bytes of logs for ModBusModule
<6> 2024-01-10 08:35:37.319 +00:00 [INF] - Successfully handled request GetModuleLogs
<6> 2024-01-10 08:36:06.089 +00:00 [INF] - Received direct method call - ping
<6> 2024-01-10 08:36:06.089 +00:00 [INF] - Received request ping with payload
<6> 2024-01-10 08:36:06.089 +00:00 [INF] - Successfully handled request ping
<6> 2024-01-10 08:36:06.182 +00:00 [INF] - Received direct method call - GetModuleLogs
<6> 2024-01-10 08:36:06.182 +00:00 [INF] - Received request GetModuleLogs with payload
<6> 2024-01-10 08:36:06.183 +00:00 [INF] - Processing request to get logs for {"schemaVersion":"1.0","items":{"id":"\\bedgeAgent\\b","filter":{"tail":1500,"since":"15m","until":null,"loglevel":null,"regex":""}},"encoding":1,"contentType":1}
<6> 2024-01-10 08:36:09.136 +00:00 [INF] - Initiating streaming logs for edgeAgent
<6> 2024-01-10 08:36:09.157 +00:00 [INF] - Received 1800 bytes of logs for edgeAgent
<6> 2024-01-10 08:36:09.158 +00:00 [INF] - Successfully handled request GetModuleLogs
<6> 2024-01-10 08:36:44.732 +00:00 [INF] - Received direct method call - ping
<6> 2024-01-10 08:36:44.732 +00:00 [INF] - Received request ping with payload
<6> 2024-01-10 08:36:44.732 +00:00 [INF] - Successfully handled request ping
<6> 2024-01-10 08:36:44.827 +00:00 [INF] - Received direct method call - GetModuleLogs
<6> 2024-01-10 08:36:44.828 +00:00 [INF] - Received request GetModuleLogs with payload
<6> 2024-01-10 08:36:44.828 +00:00 [INF] - Processing request to get logs for {"schemaVersion":"1.0","items":{"id":"\\bedgeHub\\b","filter":{"tail":1500,"since":"15m","until":null,"loglevel":null,"regex":""}},"encoding":1,"contentType":1}
<6> 2024-01-10 08:36:44.832 +00:00 [INF] - Initiating streaming logs for edgeHub
<6> 2024-01-10 08:36:44.834 +00:00 [INF] - Received 602 bytes of logs for edgeHub
<6> 2024-01-10 08:36:44.834 +00:00 [INF] - Successfully handled request GetModuleLogs
<6> 2024-01-10 08:40:11.234 +00:00 [INF] - Received direct method call - ping
<6> 2024-01-10 08:40:11.234 +00:00 [INF] - Received request ping with payload
<6> 2024-01-10 08:40:11.234 +00:00 [INF] - Successfully handled request ping
<6> 2024-01-10 08:40:11.310 +00:00 [INF] - Received direct method call - GetModuleLogs
<6> 2024-01-10 08:40:11.311 +00:00 [INF] - Received request GetModuleLogs with payload
<6> 2024-01-10 08:40:11.311 +00:00 [INF] - Processing request to get logs for {"schemaVersion":"1.0","items":{"id":"\\bedgeHub\\b","filter":{"tail":1500,"since":"15m","until":null,"loglevel":null,"regex":""}},"encoding":1,"contentType":1}
<6> 2024-01-10 08:40:11.317 +00:00 [INF] - Initiating streaming logs for edgeHub
<6> 2024-01-10 08:40:11.318 +00:00 [INF] - Received 647 bytes of logs for edgeHub
<6> 2024-01-10 08:40:11.319 +00:00 [INF] - Successfully handled request GetModuleLogs
<6> 2024-01-10 08:41:01.960 +00:00 [INF] - Received direct method call - ping
<6> 2024-01-10 08:41:01.960 +00:00 [INF] - Received request ping with payload
<6> 2024-01-10 08:41:01.961 +00:00 [INF] - Successfully handled request ping
<6> 2024-01-10 08:41:02.046 +00:00 [INF] - Received direct method call - GetModuleLogs
<6> 2024-01-10 08:41:02.046 +00:00 [INF] - Received request GetModuleLogs with payload
<6> 2024-01-10 08:41:02.046 +00:00 [INF] - Processing request to get logs for {"schemaVersion":"1.0","items":{"id":"\\bModBusModule\\b","filter":{"tail":1500,"since":"15m","until":null,"loglevel":null,"regex":""}},"encoding":1,"contentType":1}
<6> 2024-01-10 08:41:02.053 +00:00 [INF] - Initiating streaming logs for ModBusModule
<6> 2024-01-10 08:41:02.128 +00:00 [INF] - Received 2126 bytes of logs for ModBusModule
<6> 2024-01-10 08:41:02.128 +00:00 [INF] - Successfully handled request GetModuleLogs
<6> 2024-01-10 08:43:07.568 +00:00 [INF] - Received direct method call - ping
<6> 2024-01-10 08:43:07.568 +00:00 [INF] - Received request ping with payload
<6> 2024-01-10 08:43:07.568 +00:00 [INF] - Successfully handled request ping
<6> 2024-01-10 08:43:07.648 +00:00 [INF] - Received direct method call - GetModuleLogs
<6> 2024-01-10 08:43:07.648 +00:00 [INF] - Received request GetModuleLogs with payload
<6> 2024-01-10 08:43:07.649 +00:00 [INF] - Processing request to get logs for {"schemaVersion":"1.0","items":{"id":"\\bedgeAgent\\b","filter":{"tail":1500,"since":"15m","until":null,"loglevel":null,"regex":""}},"encoding":1,"contentType":1}

edge-hub logs
<6> 2024-01-10 08:25:17.959 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<6> 2024-01-10 08:26:00.333 +00:00 [INF] - Obtained edge hub config patch update from module twin
<6> 2024-01-10 08:26:00.377 +00:00 [INF] - Updating edge hub configuration
<6> 2024-01-10 08:26:00.398 +00:00 [INF] - Set the following 1 route(s) in edge hub
<6> 2024-01-10 08:26:00.398 +00:00 [INF] - ModBusModuleToIoTHub: FROM /messages/modules/ModBusModule/outputs/* INTO $upstream
<6> 2024-01-10 08:26:00.398 +00:00 [INF] - Updated message store TTL to 7200 seconds
<6> 2024-01-10 08:26:00.398 +00:00 [INF] - Updated the edge hub store and forward configuration
<6> 2024-01-10 08:26:00.551 +00:00 [INF] - Updated reported properties for Arno-dev/$edgeHub
<4> 2024-01-10 08:27:13.667 +00:00 [WRN] - "TLS handshake failed., System.IO.IOException: Channel is closed, 79206572"
<6> 2024-01-10 08:30:17.959 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<4> 2024-01-10 08:31:14.708 +00:00 [WRN] - "TLS handshake failed., System.IO.IOException: Channel is closed, 3a488cc2"
<4> 2024-01-10 08:32:15.057 +00:00 [WRN] - "TLS handshake failed., System.IO.IOException: Channel is closed, 7f59e19c"
<4> 2024-01-10 08:34:17.347 +00:00 [WRN] - "TLS handshake failed., System.IO.IOException: Channel is closed, 73e8128d"
<6> 2024-01-10 08:35:17.329 +00:00 [INF] - Started task to cleanup processed and stale messages for endpoint iothub
<6> 2024-01-10 08:35:17.334 +00:00 [INF] - Cleaned up 0 messages from queue for endpoint iothub and 0 messages from message store.
<6> 2024-01-10 08:35:17.958 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<4> 2024-01-10 08:35:21.015 +00:00 [WRN] - "TLS handshake failed., System.IO.IOException: Channel is closed, 37368612"
<4> 2024-01-10 08:36:27.235 +00:00 [WRN] - "TLS handshake failed., System.IO.IOException: Channel is closed, 20939f9e"
<4> 2024-01-10 08:37:37.240 +00:00 [WRN] - "TLS handshake failed., System.IO.IOException: Channel is closed, 1e2411c6"
<4> 2024-01-10 08:38:47.745 +00:00 [WRN] - "TLS handshake failed., System.IO.IOException: Channel is closed, 6671ae08"
<4> 2024-01-10 08:39:57.755 +00:00 [WRN] - "TLS handshake failed., System.IO.IOException: Channel is closed, 79c2f250"

Additional Information

Please provide any additional information that may be helpful in understanding the issue.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

Found the issue!

It was related to the TLS version used by the internal generated certificates. Mainly for the mqtt as far as I know. I’ve posed this generated certificated before.

Generated certificate used by mqtt
CONNECTED(00000003)
Can't use SSL_get_servername
depth=0 CN = dev-Virtual-Machine
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 CN = dev-Virtual-Machine
verify error:num=21:unable to verify the first certificate
verify return:1
depth=0 CN = dev-Virtual-Machine
verify return:1
---
Certificate chain
 0 s:CN = dev-Virtual-Machine
   i:CN = aziot-edge CA dev-dev
   a:PKEY: rsaEncryption, 2048 (bit); sigalg: RSA-SHA256
   v:NotBefore: Jan 11 07:17:11 2024 GMT; NotAfter: Feb 10 07:17:11 2024 GMT
-----BEGIN CERTIFICATE-----
MIIDPTCCAiWgAwIBAgIBADANBgkqhkiG9w0BAQsFADAhMR8wHQYDVQQDDBZhemlv
dC1lZGdlIENBIEFybm8tZGV2MB4XDTI0MDExMTA3MTcxMVoXDTI0MDIxMDA3MTcx
MVowHzEdMBsGA1UEAwwUYXJuby1WaXJ0dWFsLU1hY2hpbmUwggEiMA0GCSqGSIb3
DQEBAQUAA4IBDwAwggEKAoIBAQCiSj/a7cmg5IhrCgacJLOWhUJk1SwYgymamqJ3
Hq6M88ScOUMa7pkOC5SOGYkkd2+YNWoMB1iSUjc+adA0glX0202O3N8jVadUpvAC
4H99KdgXLYbLy8JJMcnLsaOvecaUgmRQa8qojbotCCFRMGJYNvFpvTqA7Xm0PRp0
IzqXwj4n98BvS5cfD66VekDm3AXWegMBdt0r6oi5aCkQBrg6Fhz7SnXx0rYnvB0h
UA5CblE234DJXi+dlGV6neMIvFPlhk5JwldcdxW6KwLvgsxBijprqBE32S8KnLRD
ik6kCcWEtzpQpEPBmUhsvVScpwoJgnaQhbwkwTjtjh2aXe4dAgMBAAGjgYEwfzAT
BgNVHSUEDDAKBggrBgEFBQcDATAoBgNVHREEITAfghRhcm5vLVZpcnR1YWwtTWFj
aGluZYIHZWRnZUh1YjAdBgNVHQ4EFgQU7UW6cngJUrN5Yn2N7AwicXRmbMEwHwYD
VR0jBBgwFoAUTQnHwD956g4HY01dpYGssO1eAXAwDQYJKoZIhvcNAQELBQADggEB
AIerOUERB8sf5YBQ2RWbuzp0ShXjwQ/S+bRKLncTa5Ka/DM7dnkMMtmqdK66yPPy
TgxfksDQFUhTsdEws0Pz9ySXZs7iAPaXlm4cQuHFbzG+TVW43znJvTlOTx/jfbY2
Vu4g9fcxSFZDIqmtoA/pFw1JRHUphosrphkiWhvDSksSVwRdY2Pq6FtywJWrUYxG
D+88CPc8vfZPjSgt7CJsDRsr+QJtPht1rqLel6csTrmV24NGyfid/4a++21ruesk
zu6XkzqshE2oyWOqBn1SKMBe13ycSP9EfJgdOtT/IOT62J92svslH7xT3eVlQe3C
b+BKGjrvAP6Z8PzR2/xvNFw=
-----END CERTIFICATE-----
---
Server certificate
subject=CN = dev-Virtual-Machine
issuer=CN = aziot-edge CA dev-dev
---
No client certificate CA names sent
Client Certificate Types: RSA sign, DSA sign, ECDSA sign
Requested Signature Algorithms: ECDSA+SHA256:ECDSA+SHA384:ECDSA+SHA512:Ed25519:Ed448:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA+SHA256:RSA+SHA384:RSA+SHA512:ECDSA+SHA224:RSA+SHA224:DSA+SHA224:DSA+SHA256:DSA+SHA384:DSA+SHA512
Shared Requested Signature Algorithms: ECDSA+SHA256:ECDSA+SHA384:ECDSA+SHA512:Ed25519:Ed448:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA+SHA256:RSA+SHA384:RSA+SHA512:ECDSA+SHA224:RSA+SHA224:DSA+SHA224:DSA+SHA256:DSA+SHA384:DSA+SHA512
Peer signing digest: SHA256
Peer signature type: RSA-PSS
Server Temp Key: X25519, 253 bits
---
SSL handshake has read 1515 bytes and written 398 bytes
Verification error: unable to verify the first certificate
---
New, TLSv1.2, Cipher is ECDHE-RSA-AES256-GCM-SHA384
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : ECDHE-RSA-AES256-GCM-SHA384
    Session-ID: B980356B0808C1D49172AB9A93E3C0B95AE8C2874403BFAECB303DEB961FAB5C
    Session-ID-ctx:
    Master-Key: 8A32BAD38CFF280E9D92B102BD3EF0E19B08D1080B559FADF2D2CFC06A5B5959939431203277E5F5F033277DE9D1B10D
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    TLS session ticket lifetime hint: 7200 (seconds)
    TLS session ticket:
    0000 - 21 57 e4 a0 8f fa 56 4f-65 46 80 7f 6a 16 ae 70   !W....VOeF..j..p
    0010 - 45 44 93 04 34 cb 05 6f-64 42 95 69 5c e4 6b fd   ED..4..odB.i\.k.
    0020 - 84 c8 62 e8 e0 43 57 8d-da 6e c1 c3 6c 26 84 8b   ..b..CW..n..l&..
    0030 - ac ee 4d 63 21 e3 ce d7-e1 17 e3 0c 4d e4 a7 bc   ..Mc!.......M...
    0040 - 70 9a 29 96 a4 7e dc 9f-b5 ce 17 fe 52 7f dd e0   p.)..~......R...
    0050 - b4 6a 2c b0 b7 2c c3 fb-e3 0e 07 28 fc 95 ea ff   .j,..,.....(....
    0060 - f6 b2 54 bf 36 c6 71 dd-ea a5 6f 7f 9a 95 85 73   ..T.6.q...o....s
    0070 - ae 66 fa fa 96 2f c9 0b-d5 13 35 6c b9 46 c2 06   .f.../....5l.F..
    0080 - 0b 7b c4 35 a3 56 69 f2-4f f9 18 83 11 3c 01 cb   .{.5.Vi.O....<..
    0090 - 0b 79 41 66 c1 43 18 b2-e5 cd e9 fa 9f 27 ab da   .yAf.C.......'..

    Start Time: 1704957636
    Timeout   : 7200 (sec)
    Verify return code: 21 (unable to verify the first certificate)
    Extended master secret: yes

In here is clearly visible that the tls version is 1.2. Now this is where the issue lays. Our modules are running in .net8.0 on the docker mcr.microsoft.com/dotnet/aspnet:8.0. As of this version of the docker tls lower then 1.3 is no longer supported (downgraded to security level 0). There are other people having the same issue with databases etc resulting in the same error TLS handshake failed. We have validated that falling back to a docker and .net version <8.0 fixes this issue (tested on .net7.0). This is however not a long term solution since both 6.0 and 7.0 will be end of support by the end of this year