Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] [IoTSDK] Issue with IotHubUnauthorizedAccess only when using X.509 Cert to GetFileUploadSasUriAsync[Bug Report] #3364

Open
tweickmans opened this issue Aug 29, 2023 · 0 comments
Labels
bug Something isn't working. IoTSDK Tracks all IoT SDK issues across the board

Comments

@tweickmans
Copy link

Hello
I implemented communication between a device and a IotHub.
I use Microsoft.Azure.devices.client 1.42.0 & Microsoft.Azure.devices.Provisioning.client 1.19.3 SDK

Context

  • OS, version, SKU and CPU architecture used: Windows 10 Enterprise | Intel(R) Core(TM) i7
  • Application's .NET Target Framework : net6.0
  • Device: Laptop

Description of the issue

I started from the following example. : provisioning/device/samples/getting started/X509Sample/ProvisioningDeviceClientSample.cs.

When uploading a file, we start by doing this:
image

Unfortunately, if we use the example: provisioning/device/samples/getting started/X509Sample/ProvisioningDeviceClientSample.cs. The call to the GetFileUploadSasUriAsync method generates an exception IotHubUnauthorizedAccess (even though the device was successfully provisioned through DPS on the IoT Hub).

After several searches, I came across other examples that allow the file upload to work, and this with authentication via x509 certificate.

It seems that you just need to replace the following lines:
image
With:
image

Definition of GetCertificateByThumbprint
image

It took me some time to get this to work, and I believe that updating the example could greatly help future users. I'm also interested in understanding the exact difference between these two calls...

...and why this difference in the call only impacts the file upload functionality.

@tweickmans tweickmans added the bug Something isn't working. label Aug 29, 2023
@github-actions github-actions bot added the IoTSDK Tracks all IoT SDK issues across the board label Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. IoTSDK Tracks all IoT SDK issues across the board
Projects
None yet
Development

No branches or pull requests

1 participant