-
Notifications
You must be signed in to change notification settings - Fork 739
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
ESP32: Unauthorized Access (401) to Blob Storage #814
Comments
I changed to using just the Shared Access key with the option SET_TRUSTED_CERT_IN_SAMPLES and the upload worked one time, then my esp paniced and when I retry I get a 403 error. Why could that be? This is essentially this issue. |
@jubueche I have answered your question on Stack Overflow: https://stackoverflow.com/questions/54245181/azure-iot-sdk-c-error-401-when-connecting-to-blob-storage/ |
In your answer you pointed me to an Arduino example that sends messages. This works fine for me. I ham trouble with the example sketch for uploading block blob data. Here is the trace of the first exception that I get:
So I guess it is something with vfprintf. |
When I first upload, it works, but afterwards I get an error (403). I am pretty sure I setup everything correctly in Azure. On question though: When configuring the blob format, it says: {i This is the line where it fails when the first upload was not successful:
|
If you use the sample as is you don't need to care about with the blob format. You should just point to where the file is: |
I see. But that is not the problem. The problem is:
Is anybody else having the same issue with ESP32 and azure? And @sergaz-msft maybe you have an ESP and can try to reproduce the error. I greatly appreciate any help. |
Quick update: Seems now that I am getting the first error over and over again. I deleted the #ifdefs for the certificate and just used the MSFT Baltimore certificate. Seems that this was the issue. Also I am using the release of 13th Decdember. |
There is a new update: espressif/esp-azure#23 |
Ok that fixed the problem. It is just a minor change. I added:
|
@jubueche, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey |
@jubueche - thanks for sharing your resolution. It seems you had to patch the iothub_client\src\iothub_client_ll_uploadtoblob.c file with the NULL check above. It would be awesome if you could submit PR for this into the iothub_ll_uploadtoblob.c code, so you are credited for this change :) . Our current tests running on Ubuntu VM didn't catch this. Espressif libraries have a panic behavior for the vsnprintf call when the %s parameter is null, and I believe most embedded C libraries will run into this. |
* Updating WolfSSL image to return errors that happen in the script (#896) * Fix that mqtt connects twice on x509 cert (#920) * Rename macro_utils DEC to CS_DEC (fix Arduino name collision) (#876) * Merge PR 847 - (issue #814) Fix uploadtoblob null pointer IoTHubResponse (#918) Bring in PR #847 (issue #814) change to fix uploadtoblob null pointer IoTHubResponse, add unit tests. * Add authentication details to connection reliability doc * Add authentication details to connection reliability doc [ACR] * refactor (#925) * release_2019_04_11_after_bump_version
* Updating WolfSSL image to return errors that happen in the script (#896) * Fix that mqtt connects twice on x509 cert (#920) * Rename macro_utils DEC to CS_DEC (fix Arduino name collision) (#876) * Merge PR 847 - (issue #814) Fix uploadtoblob null pointer IoTHubResponse (#918) Bring in PR #847 (issue #814) change to fix uploadtoblob null pointer IoTHubResponse, add unit tests. * Add authentication details to connection reliability doc * Add authentication details to connection reliability doc [ACR] * 4KB SSL support 4KB SSL incoming limit support on IoT Hub server side certificate renewal * Added RAM * refactor (#925) * release_2019_04_11_after_bump_version * Adding the macro_utils repo (#936) * Update submodules to the latest update (#961) * added MOCKABLE_FUNCTION to prov transport headers (#958) * Fix for gh issue 775 (twin/amqp not resubscribed after reconnection) * [ACR] Fix for gh issue 775 (twin/amqp not resubscribed after reconnection) * Add Device Twin service fault injection tests over AMQP * Raspi pipeline (#975) * dockerfile changes specify branch pls work move dockerfile connection set trace pi clean up update steps fixed bugs and cleaned script dockerfile work add build fix bugs remove parameters bugfix remove run on raspi remove e2e script fix horton syntax remove parameters fix job name patch condition values fix python path fix conditions clean yaml added pip fix no checkout fix job fix indent add condition fix pip step remove image variants remove script_dir variable add parser remove force flag fix dockerfile remove sudo add wget add mkdirs update syntax fix tars remove z from tar fix workdirs fix linaro path fix tar squashed bugs dockerfile patch Update Dockerfile Update Dockerfile Update sdk_build.sh Update raspi.yaml for Azure Pipelines Update raspi.yaml for Azure Pipelines dockerfile tweak add back check python Update Dockerfile Update Dockerfile Update Dockerfile Update Dockerfile add publish artifacts fix path for source_artifacts container images added docker image raspi updates listing stuff tweak script raspi tweak try fixing copyfiles add manual copy because tasks suck remove env vars and add keyvault environment variables fix drop path update dockerfile curl config move curl down further change openssl version removed call to jenkins dockfile tweaks add setcap clean steps to success clean up the code remove sudo adjust bash script line Update raspi.yaml for Azure Pipelines this is a hack might wanna redo later bump down versions add ca-certificates package fix linaro wget fix dockerfile dockerfile apt patch change up fix link clean dockerfile Update raspi.yaml for Azure Pipelines Update raspi.yaml for Azure Pipelines Update raspi.yaml for Azure Pipelines move to raspberry pi folder incorporate new cp for raspi remove fake docker files fix pathing move to jenkins script instead of inline remove old lines remove branch specific code for merge patch some stuff more sanitization more cleanup remove trace stuff more sanitization add copyright * fix link * remove space * newline * newline * Update Dockerfile * Update run_this_to_setup_a_pi_for_e2e_tests.sh * remove reference to run_tests since we don't clone * only run MQTT * switch copy order * update script * add the sudo * chmod * dockerfile fix * Run back compat test on the branch(#980) * Adding script to run back compat tests * Adding linux_back_compat.yml to enable DevOps test integration with new linux_back_compat.sh script. * add Mxchip YAML and script * Update .mxchip-ci.yml * Add comment per previous PR * Add comment * Update build.sh * Reworked build/.mxchip-ci.yml to split build and execute tasks. Also placed longer setup shell logic into build_all/mbed5/setup.sh. * Cleaning up and testing build/.mxchip-ci.yml * Changed /media path on client pc. * ... * Playing with git checkout steps in build_all/mbed5/build.sh. * Update .mxchip-ci.yml for Azure Pipelines * Update .mxchip-ci.yml for Azure Pipelines * Update linux back compat scripts to speed builds (#985) * Update .mxchip-ci.yml attempt to fix permission issues with git checkout * Update .mxchip-ci.yml for drop to client pc * Update .mxchip-ci.yml for Azure Pipelines * release_2019_04_30_after_bump_version * Update .mxchip-ci.yml for Azure Pipelines * Cleanup of .mxchip-ci.yml for PR * Update .mxchip-ci.yml to give DevOps relative path for Artifact Directory * Update setup.sh * Update setup.sh * Update build.sh * Removed script that was transfered back into build_all/mbed5/build.sh * Patch to copy command * Test .mxchip-ci.yml with local chmod change * Update .mxchip-ci.yml for Azure Pipelines * Update .mxchip-ci.yml for Azure Pipelines * update raspberry pi tests for PR validation (#995) * Reenable rsync in mbed5/build.sh * Update utpm submodule (#1000) * Implementing Prov custom payload (#984) * Update prov_auth_client.c to use renamed Azure_Base32 * Update submodules * Add script gate build to verify building with installed dependencies * Fix prov_auth_client_ut to use Azure_Base32 * Fix amqp property value that was being release early * Update unittest to for new changes * Submodule update * fix submodule patches (#1008) * Add extended platform info to product info string * Change function to have 1 return * Update transports to correctly expose GetPlatformInfo, plus tests * Change name for AMQP function definition * Fix memory leak that was discovered in new feature failure * add use_mbedtls option (#862) * remove installs (#1010) * Additional fixes for vcpkg installation * Update utpm with fix for log arg * New mxchip uart interface (#1002) * Adding initial mxchip serial interface for version control. * Update to serial_connect.py and serial_settings.py to expand error checking and variable wait times between reads based on baud rate * Improved tracking of Serial output from device by checking read before write. Also added better handling of exit command. * Create input.sh which Generates a new input txt file to be run on mxchip Serial interface. * Update build.sh, Revert git clone changes and replace with massand/GetStarted repo for mxchip. * Update .mxchip-ci.yml to copy correct bin file to mxchip * Update input.sh, Added setting upstream IoT Hub connection string. * Adding updates to serial_connect.py to intelligently wait for WiFi and IoT Hub setup to complete. * Made serial_connect.py more robust in several ways. * Added usage dictionary file to print out serial_connect.py usage * optionized clone of mxchip repo branch. * fix sas handling logic error (#972) * release_2019_05_16_after_bump_version * Jbobotek patch 2 (#1015) * Update build.sh, re-added rsync line with correct filepath. * Fix Base32/64 related files (#1009) * Raspberrypi service updates (#1013) * update yaml * add daemon information * fix spacing * increase sleep time to 10 minutes * increase to 20 minutes * add AZURECR to names * move reboot to after test * syntax fix * add back in working directory * move reboot before the run again * only publish exe files * improved steps for devops-agent * remove pattern matching * cp is more selective * flat copy means happiness * more setup explanation * OPTION_DO_WORK_FREQUENCY_IN_MS (#1023) * update samples * ifndef for http * add unit tests * unsigned int * update typing to be clear * fix unit tests * Update iothub_convenience_sample.c * update requirement messages * bigger comment * fix bug * bugfix again * update pointer syntax * for requirements update to iothubclient invalid arg * add logging for deprecated option * add negative unit test for setoption overlap * update unit testing * update unit tests * unit test fix * requirements doc * remove logInfo * more parenthesis * revert changes * remove unit test for keep alive
OS and version used: Ubuntu 18.04
SDK version used: Release Dec. 13, 2018
Target: ESP32.
Description of the issue:
I am trying to connect the ESP32 to my Blob storage. I am getting an HTTP error 401 (unauthorized access).
I am using the example: iothub_client_sample_upload_to_blob_mb.
I tried connecting using just the Shared Access Key in my connection string, but this did not work (no connection). After that I generated an SAS token in Azure (Storage Accounts -> -> Shared Access Signature) and plugged that in into my connection string.
My connection string looks like this:
static const char* connectionString = "HostName=<Host name>;DeviceId=<Device ID>;SharedAccessSignature=<inserted here without the "?" at the beginning>";
Q1: Why is there a "?" in front of the token? When I look at the connection string, at SharedAccessSignature=.. I don't see the "?".
I also set up the Endpoint in Azure under IoT Hub -> Upload files.
In the example, I am using the option
SET_TRUSTED_CERT_IN_SAMPLES
.Q2: What does that mean? I am not so familiar with basic encryption and should probably read up on that.
Q3: Why am I getting an 401 error? What could be a possible solution?
Code sample exhibiting the issue:
Console log of the issue:
Initializing SNTP
ESP platform sntp inited!
Time is not set yet. Connecting to WiFi and getting time over NTP. timeinfo.tm_year:70
Waiting for system time to be set... tm_year:0[times:1]
Starting the IoTHub client sample upload to blob with multiple blocks...
Info: Waiting for TLS connection
Info: Waiting for TLS connection
Info: Waiting for TLS connection
Info: Waiting for TLS connection
Error: Time:Thu Jan 17 22:06:00 2019 File:/home/julian/eclipse-workspace/chaze-esp32/components/esp-azure/azure-iot-sdk-c/iothub_client/src/iothub_client_ll_uploadtoblob.c Func:send_http_request Line:142 HTTP code was 401
Error: Time:Thu Jan 17 22:06:00 2019 File:/home/julian/eclipse-workspace/chaze-esp32/components/esp-azure/azure-iot-sdk-c/iothub_client/src/iothub_client_ll_uploadtoblob.c Func:IoTHubClient_LL_UploadToBlob_step1and2 Line:494 unable to HTTPAPIEX_ExecuteRequest
Error: Time:Thu Jan 17 22:06:00 2019 File:/home/julian/eclipse-workspace/chaze-esp32/components/esp-azure/azure-iot-sdk-c/iothub_client/src/iothub_client_ll_uploadtoblob.c Func:IoTHubClient_LL_UploadMultipleBlocksToBlob_Impl Line:768 error in IoTHubClient_LL_UploadToBlob_step1
Received unexpected result FILE_UPLOAD_ERROR
hello world failed to upload
Press any key to continue
The text was updated successfully, but these errors were encountered: