Azure / azure-iot-sdk-csharp

A C# SDK for connecting devices to Microsoft Azure IoT services
Other
457 stars 493 forks source link

[Bug Report] Fails to establish TPM connection #3431

Open emilm opened 5 months ago

emilm commented 5 months ago

Context

Description of the issue

Fails to acquire TPM device. It worked before but I have upgraded OS and kernel etc so it might be that or the container image being too old. I am not sure where that response comes from, whether it's a generic error or if the return codes have changed or at what level.

I use cr.microsoft.com/dotnet/runtime:6.0.15-bullseye-slim-arm32v7. With packages: libtss2-tcti-tabrmd-dev \ tpm2-tools \ tpm2-abrmd \

Host OS has : tpm2-tss 3.2.2 tpm2-tools 5.2 tpm2-abrmd 2.4.1

Code sample exhibiting the issue

using var secProvTpm = new SecurityProviderTpmHsm(deviceId);
var authenticationMethod = new DeviceAuthenticationWithTpm(deviceId, secProvTpm);
_logger.LogInformation("Creating Device Client with TPM");
deviceClient = DeviceClient.Create(iotHubHostName, authenticationMethod, Util.GetTransportTypeFromEnvironment());

Console log of the issue

`Closing TCTI conn TCTI conn closed! AbrmdWrapper: Got pointer to TctiProvInfo from abrmd! AbrmdWrapper: Unmarshaled TctiProvInfo AbrmdWrapper: Initial call to tcti_init_fn() returned 0; ctxSize = 88 AbrmdWrapper: Successfully initialized TCTI ctx

(process:1): WARNING : 15:28:19.955: Failed to create connection with service: Method ?CreateConnection? returned type ?(t)?, but expected ?(aht)? AbrmdWrapper: Unmarshaled TCTI_CTX`

emilm commented 5 months ago

I upgraded to mcr.microsoft.com/dotnet/runtime:6.0.27-bookworm-slim-arm32v7 in the container and the error disappeared but the process natively crashes:

ANOM_ABEND auid=4294967295 uid=0 gid=0 ses=4294967295 pid=9000 comm=2E4E455420546872656164506F6F6C exe="/usr/share/dotnet/dotnet" sig=11 res=1