PlatformIO Community

Azure IotHub Certificate Problem

Hi,

I try to work my way through the Iot for Beginner Course from Microsoft:

GitHub

GitHub - microsoft/IoT-For-Beginners: 12 Weeks, 24 Lessons, IoT for All!

12 Weeks, 24 Lessons, IoT for All! Contribute to microsoft/IoT-For-Beginners development by creating an account on GitHub.

In chapter 2.4 Migrate your plant to the cloud, I get stuck. For the tutorial, I use an M5-Stack (ESP32), so I edited the code accordingly. I flashed it to the Microcontroller, but receive the Serial message:

Failure in ssl handshake has the server certificate been added?

The message is coming from the “IoTHubClient_LL_DoWork(_device_ll_handle)” function.

I followed other ESP32 tutorials for the Azure Cloud, but always get stuck at this point. My “Connection String”, is working, tried it with another program.

Inside the certs.c of the AzureIoTHub-library are CA-Certificates provided. So I am clueless.

Did anybody encounter the same problem with the Azure Cloud-tutorial? What could be the issue?

Reminds me of Anybody able to successfully compile Azure SDK ESP32-dev with Arduino in PlatformIO 5.

Specifically, depending on the Azure instance you’re connecting to, you may need to activate a different certificate (azure-iot-arduino/certs.c at master · Azure/azure-iot-arduino · GitHub) through the build_flags of the platformio.ini (like, -DUSE_BALTIMORE_CERT or -DUSE_MICROSOFTAZURE_DE_CERT).

Is the project you’re using this? IoT-For-Beginners/2-farm/lessons/4-migrate-your-plant-to-the-cloud/code/wio-terminal/soil-moisture-sensor at main · microsoft/IoT-For-Beginners · GitHub

Against which Azure server + port are you connecting against?

Increase the debug level to maximum. What’s the full log?

Thanks for your reply.

I tried all 3 certificate build flags, non is working.

Yes, I used the project from IoT-For-Beginners 2.4 Migrate your plant to the cloud.

If followed the instructions correctly, i just have to add a CONNECTION_STRING = “HostName=------.azure-devices.net;DeviceId=m5stack;SharedAccessKey=------”;
Because “Iothubname”.azure.devices.net should be enough.

Processing m5stack-fire (platform: espressif32; board: m5stack-fire; framework: arduino)
----------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/m5stack-fire.html
PLATFORM: Espressif 32 (5.2.0) > M5Stack FIRE
HARDWARE: ESP32 240MHz, 4.31MB RAM, 16MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 @ 3.20005.220925 (2.0.5) 
 - tool-esptoolpy @ 1.40201.0 (4.2.1) 
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 42 compatible libraries
Scanning dependencies...
Dependency Graph
|-- ArduinoJson @ 6.17.3
|-- NTPClient @ 3.2.1
|-- Seeed Arduino RTC @ 2.0.0
|-- AzureIoTHub @ 1.6.1
|   |-- AzureIoTUtility @ 1.6.2
|   |   |-- WiFi @ 2.0.0
|   |   |-- WiFiClientSecure @ 2.0.0
|   |   |   |-- WiFi @ 2.0.0
|-- AzureIoTUtility @ 1.6.2
|   |-- WiFi @ 2.0.0
|   |-- WiFiClientSecure @ 2.0.0
|   |   |-- WiFi @ 2.0.0
|-- AzureIoTProtocol_MQTT @ 1.6.1
|   |-- AzureIoTHub @ 1.6.1
|   |   |-- AzureIoTUtility @ 1.6.2
|   |   |   |-- WiFi @ 2.0.0
|   |   |   |-- WiFiClientSecure @ 2.0.0
|   |   |   |   |-- WiFi @ 2.0.0
|   |-- AzureIoTUtility @ 1.6.2
|   |   |-- WiFi @ 2.0.0
|   |   |-- WiFiClientSecure @ 2.0.0
|   |   |   |-- WiFi @ 2.0.0
|-- AzureIoTProtocol_HTTP @ 1.6.1
|   |-- AzureIoTUtility @ 1.6.2
|   |   |-- WiFi @ 2.0.0
|   |   |-- WiFiClientSecure @ 2.0.0
|   |   |   |-- WiFi @ 2.0.0
|   |-- AzureIoTHub @ 1.6.1
|   |   |-- AzureIoTUtility @ 1.6.2
|   |   |   |-- WiFi @ 2.0.0
|   |   |   |-- WiFiClientSecure @ 2.0.0
|   |   |   |   |-- WiFi @ 2.0.0
|-- AzureIoTSocket_WiFi @ 1.0.3
|   |-- WiFi @ 2.0.0
|   |-- AzureIoTUtility @ 1.6.2
|   |   |-- WiFi @ 2.0.0
|   |   |-- WiFiClientSecure @ 2.0.0
|   |   |   |-- WiFi @ 2.0.0
|-- WiFi @ 2.0.0
|-- WiFiClientSecure @ 2.0.0
|   |-- WiFi @ 2.0.0
Building in release mode
Compiling .pio/build/m5stack-fire/src/main.cpp.o
Building .pio/build/m5stack-fire/bootloader.bin
Generating partitions .pio/build/m5stack-fire/partitions.bin
esptool.py v4.2.1
Creating esp32 image...
Merged 1 ELF section
Successfully created esp32 image.
Compiling .pio/build/m5stack-fire/libba1/NTPClient/NTPClient.cpp.o
Compiling .pio/build/m5stack-fire/lib930/Seeed Arduino RTC/DateTime.cpp.o
Compiling .pio/build/m5stack-fire/lib930/Seeed Arduino RTC/RTC_SAMD21.cpp.o
Compiling .pio/build/m5stack-fire/lib930/Seeed Arduino RTC/RTC_SAMD51.cpp.o
Compiling .pio/build/m5stack-fire/libe4c/WiFi/WiFi.cpp.o
Compiling .pio/build/m5stack-fire/libe4c/WiFi/WiFiAP.cpp.o
Compiling .pio/build/m5stack-fire/libe4c/WiFi/WiFiClient.cpp.o
Compiling .pio/build/m5stack-fire/libe4c/WiFi/WiFiGeneric.cpp.o
Compiling .pio/build/m5stack-fire/libe4c/WiFi/WiFiMulti.cpp.o
Archiving .pio/build/m5stack-fire/libba1/libNTPClient.a
Indexing .pio/build/m5stack-fire/libba1/libNTPClient.a
Compiling .pio/build/m5stack-fire/libe4c/WiFi/WiFiSTA.cpp.o
Archiving .pio/build/m5stack-fire/lib930/libSeeed Arduino RTC.a
Indexing .pio/build/m5stack-fire/lib930/libSeeed Arduino RTC.a
Compiling .pio/build/m5stack-fire/libe4c/WiFi/WiFiScan.cpp.o
Compiling .pio/build/m5stack-fire/libe4c/WiFi/WiFiServer.cpp.o
Compiling .pio/build/m5stack-fire/libe4c/WiFi/WiFiUdp.cpp.o
Compiling .pio/build/m5stack-fire/libadd/WiFiClientSecure/WiFiClientSecure.cpp.o
Compiling .pio/build/m5stack-fire/libadd/WiFiClientSecure/esp_crt_bundle.c.o
Compiling .pio/build/m5stack-fire/libadd/WiFiClientSecure/ssl_client.cpp.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/adapters/agenttime.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/adapters/platform_arduino.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/adapters/sslClient_arduino.cpp.o
Archiving .pio/build/m5stack-fire/libe4c/libWiFi.a
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/adapters/threadapi_arduino.c.o
Indexing .pio/build/m5stack-fire/libe4c/libWiFi.a
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/adapters/tickcounter.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/adapters/tlsio_arduino.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/adapters/tlsio_mbedtls.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/adapters/xlogging_dump_bytes.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/azure_base32.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/azure_base64.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/buffer.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/connection_string_parser.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/consolelogger.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/constbuffer.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/constbuffer_array.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/constbuffer_array_batcher.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/constmap.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/crt_abstractions.c.o
Archiving .pio/build/m5stack-fire/libadd/libWiFiClientSecure.a
Indexing .pio/build/m5stack-fire/libadd/libWiFiClientSecure.a
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/doublylinkedlist.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/gb_rand.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/gb_stdio.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/gb_time.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/gballoc.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/hmac.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/hmacsha256.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/http_proxy_stub.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/httpapiex.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/httpapiexsas.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/httpheaders.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/map.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/memory_data.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/optionhandler.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/sastoken.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/sha1.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/sha224.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/sha384-512.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/singlylinkedlist.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/string_token.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/string_tokenizer.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/strings.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/tlsio_options.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/urlencode.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/usha.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/utf8_checker.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/uuid.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/uws_client.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/uws_frame_encoder.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/vector.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/ws_url.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/xio.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/azure_c_shared_utility/xlogging.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/esp32/azcpgmspace.cpp.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/esp32/sample_init.cpp.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/esp8266/azcpgmspace.cpp.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/esp8266/sample_init.cpp.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/samd/NTPClientAz.cpp.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/samd/sample_init.cpp.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/samd/stdio.cpp.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/samd/time.cpp.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/umock_c/umock_c.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/umock_c/umock_c_negative_tests.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/umock_c/umock_log.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/umock_c/umockalloc.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/umock_c/umockautoignoreargs.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/umock_c/umockcall.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/umock_c/umockcallpairs.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/umock_c/umockcallrecorder.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/umock_c/umockstring.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/umock_c/umocktypename.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/umock_c/umocktypes.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/umock_c/umocktypes_bool.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/umock_c/umocktypes_c.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/umock_c/umocktypes_charptr.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/umock_c/umocktypes_stdint.c.o
Compiling .pio/build/m5stack-fire/lib6dc/AzureIoTUtility/umock_c/umocktypes_wcharptr.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/agenttypesystem.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/certs/certs.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/codefirst.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/commanddecoder.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/datamarshaller.c.o
Archiving .pio/build/m5stack-fire/lib6dc/libAzureIoTUtility.a
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/datapublisher.c.o
Indexing .pio/build/m5stack-fire/lib6dc/libAzureIoTUtility.a
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/dataserializer.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/iotdevice.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/iothub.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/iothub_client.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/iothub_client_authorization.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/iothub_client_core.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/iothub_client_core_ll.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/iothub_client_diagnostic.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/iothub_client_edge.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/iothub_client_ll.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/iothub_client_ll_uploadtoblob.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/iothub_client_retry_control.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/iothub_device_client.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/iothub_device_client_ll.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/iothub_message.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/iothub_module_client.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/iothub_module_client_ll.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/iothub_transport_ll_private.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/iothubtransport.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/iothubtransport_mqtt_common.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/iothubtransporthttp.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/iothubtransportmqtt.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/jsondecoder.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/jsonencoder.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/message_queue.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/methodreturn.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/multitree.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/parson.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/schema.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/schemalib.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/schemaserializer.c.o
Compiling .pio/build/m5stack-fire/libaac/AzureIoTHub/version.c.o
Compiling .pio/build/m5stack-fire/lib9a7/AzureIoTProtocol_MQTT/azure_umqtt_c/mqtt_client.c.o
Compiling .pio/build/m5stack-fire/lib9a7/AzureIoTProtocol_MQTT/azure_umqtt_c/mqtt_codec.c.o
Compiling .pio/build/m5stack-fire/lib9a7/AzureIoTProtocol_MQTT/azure_umqtt_c/mqtt_message.c.o
Compiling .pio/build/m5stack-fire/lib05b/AzureIoTProtocol_HTTP/azure_uhttp_c/httpapi_compact.c.o
Compiling .pio/build/m5stack-fire/lib2e0/AzureIoTSocket_WiFi/socketio_esp32wifi.cpp.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/Esp.cpp.o
Archiving .pio/build/m5stack-fire/lib9a7/libAzureIoTProtocol_MQTT.a
Indexing .pio/build/m5stack-fire/lib9a7/libAzureIoTProtocol_MQTT.a
Compiling .pio/build/m5stack-fire/FrameworkArduino/FirmwareMSC.cpp.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/FunctionalInterrupt.cpp.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/HWCDC.cpp.o
Archiving .pio/build/m5stack-fire/libaac/libAzureIoTHub.a
Archiving .pio/build/m5stack-fire/lib05b/libAzureIoTProtocol_HTTP.a
Indexing .pio/build/m5stack-fire/lib05b/libAzureIoTProtocol_HTTP.a
Indexing .pio/build/m5stack-fire/libaac/libAzureIoTHub.a
Compiling .pio/build/m5stack-fire/FrameworkArduino/HardwareSerial.cpp.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/IPAddress.cpp.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/IPv6Address.cpp.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/MD5Builder.cpp.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/Print.cpp.o
.pio/libdeps/m5stack-fire/AzureIoTSocket_WiFi/src/socketio_esp32wifi.cpp: In function 'int socketio_send(CONCRETE_IO_HANDLE, const void*, size_t, ON_SEND_COMPLETE, void*)':
.pio/libdeps/m5stack-fire/AzureIoTSocket_WiFi/src/socketio_esp32wifi.cpp:444:90: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
                     if (add_pending_io(socket_io_instance, (const unsigned char*)(buffer + send_result), size - send_result, on_send_complete, callback_context) != 0)
                                                                                   ~~~~~~~^~~~~~~~~~~~~
Archiving .pio/build/m5stack-fire/lib2e0/libAzureIoTSocket_WiFi.a
Indexing .pio/build/m5stack-fire/lib2e0/libAzureIoTSocket_WiFi.a
Compiling .pio/build/m5stack-fire/FrameworkArduino/Stream.cpp.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/StreamString.cpp.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/Tone.cpp.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/USB.cpp.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/USBCDC.cpp.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/USBMSC.cpp.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/WMath.cpp.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/WString.cpp.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/base64.cpp.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/cbuf.cpp.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/esp32-hal-adc.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/esp32-hal-bt.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/esp32-hal-cpu.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/esp32-hal-dac.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/esp32-hal-gpio.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/esp32-hal-i2c-slave.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/esp32-hal-i2c.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/esp32-hal-ledc.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/esp32-hal-matrix.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/esp32-hal-misc.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/esp32-hal-psram.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/esp32-hal-rgb-led.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/esp32-hal-rmt.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/esp32-hal-sigmadelta.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/esp32-hal-spi.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/esp32-hal-time.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/esp32-hal-timer.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/esp32-hal-tinyusb.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/esp32-hal-touch.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/esp32-hal-uart.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/firmware_msc_fat.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/libb64/cdecode.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/libb64/cencode.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/main.cpp.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/stdlib_noniso.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/wiring_pulse.c.o
Compiling .pio/build/m5stack-fire/FrameworkArduino/wiring_shift.c.o
Archiving .pio/build/m5stack-fire/libFrameworkArduino.a
Indexing .pio/build/m5stack-fire/libFrameworkArduino.a
Linking .pio/build/m5stack-fire/firmware.elf
Retrieving maximum program size .pio/build/m5stack-fire/firmware.elf
Checking size .pio/build/m5stack-fire/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.9% (used 40840 bytes from 4521984 bytes)
Flash: [=         ]  14.6% (used 956821 bytes from 6553600 bytes)
Building .pio/build/m5stack-fire/firmware.bin
esptool.py v4.2.1
Creating esp32 image...
Merged 25 ELF sections
Successfully created esp32 image

I also tried this command to find the right certificate. Tried both but did not work either.
openssl s_client -showcerts -connect “Iothubname”.azure-devices.net:443

I mean this in regards to the serial output. The TLS client should at least print to which exact host+port it wants to establish the TLS conenction to.

If you have openssl installed (also downloadable for windows), you can use

openssl s_client -connect “someserver.com:portnumber” -showcerts

to have a look at what root certificate it sends.

read this

That is strange, I dont get any information from the TLS Client. Log at the end.

I also tried this command to find the correct certificate. Tried both from the command reply, but non was working.

Connecting to WiFi..
[  1501][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 0 - WIFI_READY
[  1694][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
[  1693][V][WiFiGeneric.cpp:338] _arduino_event_cb(): STA Started
[  1759][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 2 - STA_START
[  1854][V][WiFiGeneric.cpp:360] _arduino_event_cb(): STA Disconnected: SSID: HH40V_5E96, BSSID: 94:27:90:e4:5e:96, Reason: 202
[  1977][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED
[  2069][W][WiFiGeneric.cpp:950] _eventCallback(): Reason: 202 - AUTH_FAIL
[  2148][D][WiFiGeneric.cpp:966] _eventCallback(): WiFi Reconnect Running
[  2228][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
Connecting to WiFi..
[  2416][V][WiFiGeneric.cpp:353] _arduino_event_cb(): STA Connected: SSID: HH40V_5E96, BSSID: 94:27:90:e4:5e:96, Channel: 1, Auth: WPA2_PSK
[  2482][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
[  2527][V][WiFiGeneric.cpp:360] _arduino_event_cb(): STA Disconnected: SSID: HH40V_5E96, BSSID: 94:27:90:e4:5e:96, Reason: 8
[  2525][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 4 - STA_CONNECTED
[  2875][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED
[  2967][W][WiFiGeneric.cpp:950] _eventCallback(): Reason: 8 - ASSOC_LEAVE
[  3101][V][WiFiGeneric.cpp:353] _arduino_event_cb(): STA Connected: SSID: HH40V_5E96, BSSID: 94:27:90:e4:5e:96, Channel: 1, Auth: WPA2_PSK
[  3193][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 4 - STA_CONNECTED
[  3208][V][WiFiGeneric.cpp:367] _arduino_event_cb(): STA Got New IP:192.168.1.240
[  3369][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
[  3454][D][WiFiGeneric.cpp:991] _eventCallback(): STA IP: 192.168.1.240, MASK: 255.255.255.0, GW: 192.168.1.1
Connected to Wifi!
1668887928
 IoTHubClient_CreateFromConnectionString Ceated
Setup Fertig !
Sending telemetry {"soil_moisture":166}
Senden Fertig !
Error: Time:Sat Nov 19 19:58:57 2022 File:.pio/libdeps/m5stack-fire/AzureIoTUtility/src/adapters/tlsio_mbedtls.c Func:on_underlying_io_open_complete Line:191 Failure in ssl handshake has the server certificate been added?
Error: Time:Sat Nov 19 19:58:57 2022 File:.pio/libdeps/m5stack-fire/AzureIoTProtocol_MQTT/src/azure_umqtt_c/mqtt_client.c Func:onOpenComplete Line:454 Error: failure opening connection to endpoint
Sending telemetry {"soil_moisture":162}
Senden Fertig !
Sending telemetry {"soil_moisture":158}
Senden Fertig !

Can you upload your project, but wihtout the secret parts of the connection string?

Or can you modify the code so that it prints to which server + port it wants to connect so that we can check the root certificate it uses?

I will upload my project-folder to a shared Dropboxfolder and clear wifi and azure key.

Thank you for your help.

Thanks, will read about it.

How would I do that? I searched for he esp-tls library, but i still don’t know how to output tls log, because the used function is inside the Azure Iot Library ( well hidden).

The easiest is to look for the caller, not deep in the library – it’s in the Azure libraries somewhere that decide to what server + port to connect based on your connection string.

I still have to take a look later.

I looked for it on the weekend, but did not find it. I found out that the function ends in the esp32_ssl library, but from there I am blind.
The certificate is inside the certificate variable, I printed it on the serial port to make sure it’s there, but the function that tries to establish the connection can’t find it.

Maybe someone knows what needs to be done, I will try it again on the next weekend.

So after reading through every failure message. I found a solution for my problem.

All certificates are in the variable certificates, so you can print it on the serial port, but it’s not set.
If you use the function below, it’s set and connects with the Azure Iot Hub

IoTHubDeviceClient_LL_SetOption(whateveryourhandleis, OPTION_TRUSTED_CERT, certificates);

The Iot-For-Beginners does not include this line, just add it and everything works.