Azure / Azure/azure-storage-cpplite

request signing failed when accessing Azure Blob Storage on IoT Edge

Open
#24 4 comments 0 reactions 1 assignee Claimed by @katmsft View on GitHub
bug
Dominant language
C++
Stars
26
Forks
50
PR merge metrics
No merged PRs in 30d

Description

I was trying to run the SDK on an Embedded Linux device running as IoT leaf to access [Azure Blob Storage on IoT Edge](https://docs.microsoft.com/en-us/azure/iot-edge/how-to-store-data-blob). However authorization kept failing. Meanwhile Azure Storage .Net SDK worked just fine.

After some digging, I narrowed down the problem to request signing. The client side (leaf device) signed a different header compared to what sever (Blob Storage on IoT Edge) saw. For example, client signed the header as:
```
PUT

x-ms-client-request-id:4cb210a3-2560-4da4-85a2-8c76ddd10336
x-ms-date:Mon, 13 May 2019 03:14:11 GMT
x-ms-version:2018-03-28
/mymoxa2/cont1
restype:container
```
While the server saw:
```
PUT

x-ms-client-request-id:4cb210a3-2560-4da4-85a2-8c76ddd10336
x-ms-date:Mon, 13 May 2019 03:14:11 GMT
x-ms-version:2018-03-28
/mymoxa2/mymoxa2/cont1
restype:container
```
The difference was with resource path `/mymoxa2/cont1` vs `/mymoxa2/mymoxa2/cont1`. It tracked down to `shared_key_credential::sign_request` function in [storage_credential.cpp](https://github.com/Azure/azure-storage-cpplite/blob/master/src/storage_credential.cpp). My temporary hack was to append account name twice. Then it worked. I am not security expert and I bet you'll come up with a better fix.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.