Azure / azure-iot-sdk-python

A Python SDK for connecting devices to Microsoft Azure IoT services
MIT License
423 stars 377 forks source link

Blob upload using x509 certs #200

Closed Vijay-Karthick closed 6 years ago

Vijay-Karthick commented 6 years ago

Hi,

I have a device communicating to my IoT Hub using CA signed certificates (proof of possession has been done) communicating using MQTT protocol.

I'm able to successfully communicate to the Hub. But I'm not able to upload files to blob.

However, I'm able to upload files successfully from a device authenticated using SAS token using the procedure in https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-python-python-file-upload to the same IoT Hub.

Can you please tell me why upload to blob works from a device authenticated via SAS token (on MQTT and HTTP) but not from a device authenticated via TLS certificate (on MQTT)?

Kind regards, Vijay.

Vijay-Karthick commented 6 years ago

Output trace for device authenticated via X509 certs on MQTT:

Simulating a file upload using the Azure IoT Hub Device SDK for Python
    Protocol MQTT
IoT Hub file upload sample, press Ctrl-C to exit

File upload initiated...
Error: Time:Thu Sep 20 11:15:40 2018 File:C:\Release\iot-sdks-internals\release\python\automation\aziotsdk_pytools\src\c\c-utility\adapters\httpapi_winhttp.c Func:HTTPAPI_CloneOption Line:1046 unknown option CURLOPT_VERBOSE
Error: Time:Thu Sep 20 11:15:40 2018 File:C:\Release\iot-sdks-internals\release\python\automation\aziotsdk_pytools\src\c\c-utility\src\httpapiex.c Func:HTTPAPIEX_SetOption Line:609 error code = HTTPAPIEX_INVALID_ARG
Error: Time:Thu Sep 20 11:15:40 2018 File:C:\Release\iot-sdks-internals\release\python\automation\aziotsdk_pytools\src\c\iothub_client\src\iothub_client_ll_uploadtoblob.c Func:IoTHubClient_LL_UploadToBlob_step1and2 Line:298 HTTP code was 401
Error: Time:Thu Sep 20 11:15:40 2018 File:C:\Release\iot-sdks-internals\release\python\automation\aziotsdk_pytools\src\c\iothub_client\src\iothub_client_ll_uploadtoblob.c Func:IoTHubClient_LL_UploadMultipleBlocksToBlob_Impl Line:939 error in IoTHubClient_LL_UploadToBlob_step1
Error: Time:Thu Sep 20 11:15:40 2018 File:C:\Release\iot-sdks-internals\release\python\automation\aziotsdk_pytools\src\c\iothub_client\src\iothub_client_core.c Func:uploadingThread Line:2124 unable to IoTHubClientCore_LL_UploadToBlob
...file upload callback returned: ERROR

Output trace for device authenticated via SAS token on MQTT:

Simulating a file upload using the Azure IoT Hub Device SDK for Python
    Protocol MQTT
IoT Hub file upload sample, press Ctrl-C to exit

File upload initiated...
Error: Time:Thu Sep 20 11:22:06 2018 File:C:\Release\iot-sdks-internals\release\python\automation\aziotsdk_pytools\src\c\c-utility\adapters\httpapi_winhttp.c Func:HTTPAPI_CloneOption Line:1046 unknown option CURLOPT_VERBOSE
Error: Time:Thu Sep 20 11:22:06 2018 File:C:\Release\iot-sdks-internals\release\python\automation\aziotsdk_pytools\src\c\c-utility\src\httpapiex.c Func:HTTPAPIEX_SetOption Line:609 error code = HTTPAPIEX_INVALID_ARG
...file uploaded successfully.

Output trace for device authenticated via SAS token on HTTP:

Simulating a file upload using the Azure IoT Hub Device SDK for Python
    Protocol HTTP
IoT Hub file upload sample, press Ctrl-C to exit

File upload initiated...
Error: Time:Thu Sep 20 11:23:01 2018 File:C:\Release\iot-sdks-internals\release\python\automation\aziotsdk_pytools\src\c\c-utility\adapters\httpapi_winhttp.c Func:HTTPAPI_CloneOption Line:1046 unknown option CURLOPT_VERBOSE
Error: Time:Thu Sep 20 11:23:01 2018 File:C:\Release\iot-sdks-internals\release\python\automation\aziotsdk_pytools\src\c\c-utility\src\httpapiex.c Func:HTTPAPIEX_SetOption Line:609 error code = HTTPAPIEX_INVALID_ARG
...file uploaded successfully.

Kind regards, Vijay.

pierreca commented 6 years ago

I believe this is a limitation of the service, not much the SDK can do about that. Closing since we cannot act on it here.

for reference, from another SDK: https://github.com/Azure/azure-iot-sdk-node/issues/302

az-iot-builder-01 commented 6 years ago

@Vijay-Karthick, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey