WiFiClientSecure GET request to an HTTPS server

Hello, I am trying to run the following example to make a GET to an https server but I get this error when the start_ssl_client() function is called.
I would really appreciate any help on this issue.
Error:

[HTTPS] begin...
[HTTPS] GET...
[  3090][E][ssl_client.cpp:37] _handle_error(): [start_ssl_client():273]: (-29696) SSL - No RNG was provided to the SSL module
[  3102][E][WiFiClientSecure.cpp:144] connect(): start_ssl_client: -29696

Here is my platformio.ini

[env:esp32-s3-devkitc-1]
platform = espressif32@6.9.0
board = esp32-s3-devkitc-1
framework = arduino
build_flags= 
    -DBOARD_HAS_PSRAM 
    -DARDUINO_USB_MODE=1 
    -DARDUINO_USB_CDC_ON_BOOT=1 
monitor_filters = esp32_exception_decoder

The code:

#include <Arduino.h>
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <HTTPClient.h>

// Replace with your network credentials
const char *ssid = "xxxxxx";
const char *password = "xxxxxxxx";

// www.howsmyssl.com root certificate authority, to verify the server
// change it to your server root CA
const char* rootCACertificate = \
     "-----BEGIN CERTIFICATE-----\n" \
     "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\n" \
     "-----END CERTIFICATE-----\n";

void setup()
{
  Serial.begin(115200);
  Serial.println();
  // Initialize Wi-Fi
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.print("Connecting to WiFi ..");
  while (WiFi.status() != WL_CONNECTED)
  {
    Serial.print('.');
    delay(1000);
  }
  Serial.println(WiFi.localIP());
}

void loop()
{
  WiFiClientSecure *client = new WiFiClientSecure;
  if (client)
  {
    // set secure client without certificate
    client->setInsecure();
    // create an HTTPClient instance
    HTTPClient https;

    // Initializing an HTTPS communication using the secure client
    Serial.print("[HTTPS] begin...\n");
    if (https.begin(*client, "https://www.howsmyssl.com/a/check"))
    { // HTTPS
      Serial.print("[HTTPS] GET...\n");
      // start connection and send HTTP header
      int httpCode = https.GET();
      // httpCode will be negative on error
      if (httpCode > 0)
      {
        // HTTP header has been send and Server response header has been handled
        Serial.printf("[HTTPS] GET... code: %d\n", httpCode);
        // file found at server
        if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY)
        {
          // print server response payload
          String payload = https.getString();
          Serial.println(payload);
        }
      }
      else
      {
        Serial.printf("[HTTPS] GET... failed, error: %s\n", https.errorToString(httpCode).c_str());
      }
      https.end();
    }
  }
  else
  {
    Serial.printf("[HTTPS] Unable to connect\n");
  }
  Serial.println();
  Serial.println("Waiting 2min before the next round...");
  delay(120000);
}

Hi @pjmd !

That code runs perfectly on an ESP32-S3.

Connecting to WiFi ...192.168.2.189
[HTTPS] begin...
[HTTPS] GET...
[HTTPS] GET... code: 200
{"given_cipher_suites":["TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384","TLS_DHE_RSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_256_CCM",...

See ESP32-S3 HTTPS Request - Wokwi ESP32, STM32, Arduino Simulator

Try a full clean, then build and upload again:
PIO Icon / Project Tasks / Default / General /Full Clean

Hello @sivar2311 , Thank you for looking into it. Indeed, the simulator is perfectly fine with this code but even after a full clean, in real life with my ESP32-S3-DevKitc-1 N8R from Espressif, it doesn’t work. I get the same error.

Please double check the naming of your DevKit!

The ESP32-S3-N8 (without an R plus a following number) doesn’t have PSRAM!
So you have to remove -DBOARD_HAS_PSRAM from the build_flags.

See my list of configurations for various ESP32-S3 modules:

1 Like

Actually it is an ESP32-S3-WROOM-1-N8R2. I copied the extra bits I was missing from you conf ESP32-S3-WROOM-(1/1U)-N8R2 i.e.

board_build.arduino.memory_type = qio_qspi
board_build.flash_mode = qio
board_build.psram_type = qio
board_upload.flash_size = 8MB
board_upload.maximum_size = 8388608
board_build.extra_flags = 
  -DBOARD_HAS_PSRAM

I still get the error:

[ssl_client.cpp:37] _handle_error(): [start_ssl_client():273]: (-29696) SSL - No RNG was provided to the SSL module

Now if I replace platform = espressif32@6.9.0 with just platform = espressif32, the include file #include <WiFiClientSecure.h> cannot be found. So I must be missing something, I guess.

Looks like you have multpile Espressif32 platforms installed. And one of them is broken.
Remove the non 6.9.0 platform.

True I had multiple platforms installed. Removing them fixed the WiFiClientSecure.h not found. The *start_ssl_client() issue is still bothering me.

Did you perform a clean / full clean after removing the platform? There might be some corrupted leftovers in the cache.

Yes, I thought about it and did a full clean.

Last thing I would try is to wipe the platform and packages folder in c:\users\<username>\.platformio
Then restart VS Code and let PIO reinstall the platform and package files. This might take a few minutes.

I wiped out packages and platform to no avail. Here is the full stack trace:

  #0  0x403771c2 in panic_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/panic.c:408
  #1  0x4037c061 in esp_system_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/esp_system.c:137
  #2  0x40381dd9 in __assert_func at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/newlib/assert.c:85
  #3  0x40377a12 in heap_caps_free at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/heap_caps.c:381
      (inlined by) heap_caps_free at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/heap_caps.c:366
  #4  0x40379035 in esp_mbedtls_mem_free at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/mbedtls/port/esp_mem.c:46
  #5  0x4204c6ee in mbedtls_free at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/mbedtls/mbedtls/library/platform.c:54
  #6  0x4203e744 in mbedtls_ssl_free at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/mbedtls/mbedtls/library/ssl_tls.c:6807
  #7  0x420060d7 in stop_ssl_socket(sslclient_context*, char const*, char const*, char const*) at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src/ssl_client.cpp:336       
  #8  0x42004f04 in WiFiClientSecure::stop() at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src/WiFiClientSecure.cpp:98
  #9  0x42005175 in WiFiClientSecure::connect(IPAddress, unsigned short, char const*, char const*, char const*, char const*) at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src/WiFiClientSecure.cpp:145
  #10 0x420051db in WiFiClientSecure::connect(char const*, unsigned short, char const*, char const*, char const*) at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src/WiFiClientSecure.cpp:136
  #11 0x420052aa in WiFiClientSecure::connect(char const*, unsigned short) at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src/WiFiClientSecure.cpp:117
      (inlined by) WiFiClientSecure::connect(char const*, unsigned short) at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src/WiFiClientSecure.cpp:113
  #12 0x42092c59 in WiFiClientSecure::connect(char const*, unsigned short, int) at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src/WiFiClientSecure.cpp:122
  #13 0x42007145 in HTTPClient::connect() at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/libraries/HTTPClient/src/HTTPClient.cpp:1162
      (inlined by) HTTPClient::connect() at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/libraries/HTTPClient/src/HTTPClient.cpp:1126
  #14 0x42008413 in HTTPClient::sendRequest(char const*, unsigned char*, unsigned int) at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/libraries/HTTPClient/src/HTTPClient.cpp:601
  #15 0x4200866b in HTTPClient::GET() at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/libraries/HTTPClient/src/HTTPClient.cpp:518
  #16 0x42002ed7 in loop() at src/main.cpp:78
  #17 0x4200b441 in loopTask(void*) at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:50

That’s totally weird.
Is the code still 100% exact to the first post WiFiClientSecure GET request to an HTTPS server ?

Btw. the error has changed from “[ssl_client.cpp:37] _handle_error(): [start_ssl_client():273]: (-29696) SSL - No RNG was provided to the SSL module” to a crash !?

The issue is unchanged. As far as I can see/understand, the error happens in WiFiClientSecure::connect, the pointer to the rng function in the ctx is null, it then returns, calls stop(), and finally crashes badly, hence the stack trace. The root cause is still No RNG was provided to the SSL module

But the error changed to a crash?!

Please provide the full project.

Hello, I decided to try in WSL (Ubuntu-22.04) and it worked without a hitch. Tried again in Windows same code, same platformio.ini and I got the error SSL - No RNG was provided to the SSL module.
Not sure we want to spend more time on this issue, I am perfectly fine working on my project in WSL (maybe this environment is cleaner),.
I am pasting below platfomio.ini, the code, and full error message just in case.

[env:esp32-s3-devkitc-1]
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
build_flags= 
   -DBOARD_HAS_PSRAM 
    -DARDUINO_USB_MODE=1 
    -DARDUINO_USB_CDC_ON_BOOT=1 
monitor_filters = esp32_exception_decoder
; monitor_speed = 115200
board_build.arduino.memory_type = qio_qspi
board_build.flash_mode = qio
board_build.psram_type = qio
board_upload.flash_size = 8MB
board_upload.maximum_size = 8388608
#include <Arduino.h>
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <HTTPClient.h>

// Replace with your network credentials
const char *ssid = "SSID";
const char *password = "PASSWD";

// www.howsmyssl.com root certificate authority, to verify the server
// change it to your server root CA
const char* rootCACertificate = \
     "-----BEGIN CERTIFICATE-----\n" \
     "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\n" \
     "-----END CERTIFICATE-----\n";
     
void setup()
{
  Serial.begin(115200);
  Serial.println();
  // Initialize Wi-Fi
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.print("Connecting to WiFi ..");
  while (WiFi.status() != WL_CONNECTED)
  {
    Serial.print('.');
    delay(1000);
  }
  Serial.println(WiFi.localIP());
}

void loop()
{
  WiFiClientSecure *client = new WiFiClientSecure;
  if (client)
  {
    // set secure client without certificate
    client->setInsecure();
    // create an HTTPClient instance
    HTTPClient https;

    // Initializing an HTTPS communication using the secure client
    Serial.print("[HTTPS] begin...\n");
    if (https.begin(*client, "https://www.howsmyssl.com/a/check"))
    { // HTTPS
      Serial.print("[HTTPS] GET...\n");
      // start connection and send HTTP header
      int httpCode = https.GET();
      // httpCode will be negative on error
      if (httpCode > 0)
      {
        // HTTP header has been send and Server response header has been handled
        Serial.printf("[HTTPS] GET... code: %d\n", httpCode);
        // file found at server
        if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY)
        {
          // print server response payload
          String payload = https.getString();
          Serial.println(payload);
        }
      }
      else
      {
        Serial.printf("[HTTPS] GET... failed, error: %s\n", https.errorToString(httpCode).c_str());
      }
      https.end();
    }
  }
  else
  {
    Serial.printf("[HTTPS] Unable to connect\n");
  }
  Serial.println();
  Serial.println("Waiting 2min before the next round...");
  delay(30000);
}

Error:

Connecting to WiFi ...192.168.1.30
[HTTPS] begin...
[HTTPS] GET...
[  4019][E][ssl_client.cpp:37] _handle_error(): [start_ssl_client():273]: (-29696) SSL - No RNG was provided to the SSL module
[  4030][E][WiFiClientSecure.cpp:144] connect(): start_ssl_client: -29696

assert failed: heap_caps_free heap_caps.c:381 (heap != NULL && "free() target pointer is outside heap areas")


Backtrace: 0x403779b2:0x3fcebb40 0x4037cd71:0x3fcebb60 0x40382c2d:0x3fcebb80 0x40378202:0x3fcebcb0 0x403798ad:0x3fcebcd0 0x4204b906:0x3fcebcf0 0x4203d990:0x3fcebd10 0x4200615b:0x3fcebd30 0x42004f88:0x3fcebd50 0x420051f9:0x3fcebd70 0x4200525f:0x3fcebdc0 0x4200532e:0x3fcebe00 0x42091e19:0x3fcebe20 0x420071c9:0x3fcebe40 0x42008497:0x3fcebe70 0x420086ef:0x3fcebee0 0x42002f5b:0x3fcebf00 0x4200ac69:0x3fcec000
  #0  0x403779b2 in panic_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/panic.c:408
  #1  0x4037cd71 in esp_system_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_system/esp_system.c:137
  #2  0x40382c2d in __assert_func at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/newlib/assert.c:85
  #3  0x40378202 in heap_caps_free at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/heap_caps.c:381
      (inlined by) heap_caps_free at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/heap_caps.c:366
  #4  0x403798ad in esp_mbedtls_mem_free at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/mbedtls/port/esp_mem.c:46
  #5  0x4204b906 in mbedtls_free at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/mbedtls/mbedtls/library/platform.c:54
  #6  0x4203d990 in mbedtls_ssl_free at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/mbedtls/mbedtls/library/ssl_tls.c:6807
  #7  0x4200615b in stop_ssl_socket(sslclient_context*, char const*, char const*, char const*) at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src/ssl_client.cpp:336
  #8  0x42004f88 in WiFiClientSecure::stop() at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src/WiFiClientSecure.cpp:98
  #9  0x420051f9 in WiFiClientSecure::connect(IPAddress, unsigned short, char const*, char const*, char const*, char const*) at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src/WiFiClientSecure.cpp:145
  #10 0x4200525f in WiFiClientSecure::connect(char const*, unsigned short, char const*, char const*, char const*) at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src/WiFiClientSecure.cpp:136
  #11 0x4200532e in WiFiClientSecure::connect(char const*, unsigned short) at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src/WiFiClientSecure.cpp:117
      (inlined by) WiFiClientSecure::connect(char const*, unsigned short) at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src/WiFiClientSecure.cpp:113
  #12 0x42091e19 in WiFiClientSecure::connect(char const*, unsigned short, int) at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src/WiFiClientSecure.cpp:122
  #13 0x420071c9 in HTTPClient::connect() at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/libraries/HTTPClient/src/HTTPClient.cpp:1162
      (inlined by) HTTPClient::connect() at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/libraries/HTTPClient/src/HTTPClient.cpp:1126
  #14 0x42008497 in HTTPClient::sendRequest(char const*, unsigned char*, unsigned int) at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/libraries/HTTPClient/src/HTTPClient.cpp:601
  #15 0x420086ef in HTTPClient::GET() at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/libraries/HTTPClient/src/HTTPClient.cpp:518
  #16 0x42002f5b in loop() at src/main.cpp:77
  #17 0x4200ac69 in loopTask(void*) at C:/Users/pjmd/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:50

The last things I would try are to delete the packages and platforms folders and also the .cache folder.

If the problems still occur, I would delete the entire .platformio folder.

As you suggested I removed the entire .platformio folder and it fixed the issue. Thanks a lot for your help.