Https webserver with external library "ESP32_HTTPS_Server" on esp32

Hello guys!

Im working on a webserver with my esp32-s2-wrover-i and most of my functions are working with http. now i would like to add https connection and i faced some problems. I saw an external library which can be found at the library manager under the name: "esp32_https_server" and "esp32_https_server_compat". the compat version is a wrapper so that you can use the same API as the default webserver.h library.

If I compile the Example HelloServer i get the following error message:

Arduino: 1.8.17 Hourly Build 2021/09/06 02:33 (Windows 10), Board: "ESP32S2 Dev Module, Disabled, Disabled, Disabled, UART0, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi), DIO, 40MHz, 4MB (32Mb), 115200, None"

Mehrere Bibliotheken wurden für "ESPWebServer.hpp" gefunden

In file included from C:\Users\Student\Documents\Arduino\libraries\esp32_https_server-1.0.0\src/HTTPServer.hpp:23,

Benutzt: C:\Users\Student\Documents\Arduino\libraries\esp32_https_server_compat

Nicht benutzt: C:\Users\Student\Desktop\arduino-nightly\libraries\esp32_https_server_compat-1.0.0

Mehrere Bibliotheken wurden für "HTTPServer.hpp" gefunden

             from C:\Users\Student\Documents\Arduino\libraries\esp32_https_server_compat\src/ESPWebServer.hpp:10,

Benutzt: C:\Users\Student\Documents\Arduino\libraries\esp32_https_server-1.0.0

Nicht benutzt: C:\Users\Student\Desktop\arduino-nightly\libraries\esp32_https_server-1.0.0

Mehrere Bibliotheken wurden für "WiFi.h" gefunden

             from C:\Users\Student\Documents\Arduino\libraries\esp32_https_server_compat\examples\HelloServer\HelloServer.ino:8:

Benutzt: C:\Users\Student\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.0\libraries\WiFi

C:\Users\Student\Documents\Arduino\libraries\esp32_https_server-1.0.0\src/HTTPConnection.hpp:9:10: fatal error: hwcrypto/sha.h: No such file or directory

Nicht benutzt: C:\Users\Student\Desktop\arduino-nightly\libraries\WiFi

#include <hwcrypto/sha.h>

      ^~~~~~~~~~~~~~~~

compilation terminated.

exit status 1

Fehler beim Kompilieren für das Board ESP32S2 Dev Module.

its in german. hopefully its still understandable. it basically tells me, that an error occured for the board ESP32S2 Dev Module.

did anyone inlcuded this library and can share some experience and does the problem lay on my side and not on the library side?

thanks in advance!

example code:

#include <WiFi.h>
#include <WiFiClient.h>
#include <ESPmDNS.h>
#ifdef USE_DEFAULT_WEBSERVER
#include <WebServer.h>
typedef WebServer ESPWebServer;
#else
#include <ESPWebServer.hpp>
#endif

const char* ssid = "........";
const char* password = "........";

ESPWebServer server(80);

const int led = 13;

void handleRoot() {
  digitalWrite(led, 1);
  server.send(200, "text/plain", "hello from esp32! See /form and /inline too!");
  digitalWrite(led, 0);
}

void handleForm() {
  String line = server.arg("line");
  Serial.print("line: ");
  Serial.println(line);
  String multi = server.arg("multi");
  Serial.print("multi: ");
  Serial.println(multi);
  line.toLowerCase();
  multi.toUpperCase();
  String rv;
  rv = "<html><head><title>Test Form</title></head><body>";
  rv += "<p>Single line will be converted to lowercase, multi line to uppercase. You can submit the form with three different methods.</p>";
  rv += "<h2>Form using GET</h2>";
  rv += "<form method='GET'>";
  rv += "Single line:<br><input name='line' value='" + line + "'><br>";
  rv += "Multi line:<br><textarea name='multi' rows='8' cols='40'>" + multi + "</textarea><br>";
  rv += "<input type='submit' value='upper+lower case'>";
  rv += "</form>";
  rv += "<h2>Form using POST urlencoded</h2>";
  rv += "<form method='POST' action='/form'>";
  rv += "Single line:<br><input name='line' value='" + line + "'><br>";
  rv += "Multi line:<br><textarea name='multi' rows='8' cols='40'>" + multi + "</textarea><br>";
  rv += "<input type='submit' value='upper+lower case'>";
  rv += "</form>";
  rv += "<h2>Form using POST with multipart</h2>";
  rv += "<form method='POST' enctype=\"multipart/form-data\">";
  rv += "Single line:<br><input name='line' value='" + line + "'><br>";
  rv += "Multi line:<br><textarea name='multi' rows='8' cols='40'>" + multi + "</textarea><br>";
  rv += "<input type='submit' value='upper+lower case'>";
  rv += "</form></body></html>";
  server.send(200, "text/html", rv);
}


void handleNotFound() {
  digitalWrite(led, 1);
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET) ? "GET" : "POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i = 0; i < server.args(); i++) {
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }
  server.send(404, "text/plain", message);
  digitalWrite(led, 0);
}

void setup(void) {
  pinMode(led, OUTPUT);
  digitalWrite(led, 0);
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  if (MDNS.begin("esp32")) {
    Serial.println("MDNS responder started");
  }

  server.on("/", handleRoot);
  server.on("/form", handleForm);
  server.on("/form", HTTP_POST, handleForm);
  server.on("/inline", []() {
    server.send(200, "text/plain", "this works as well");
  });

  server.onNotFound(handleNotFound);

  server.begin();
  Serial.println("HTTP server started");
}

void loop(void) {
  server.handleClient();
}

followup question. Is there a easier way to implement https with no external library?

Hi @dansen. I see this issue has been reported in the library's bug tracker:

So you can pick either of two options for solving this error:

  • Use the Arduino IDE's Boards Manager to roll back to the compatible version of the "esp32" boards platform. I believe that is version 1.0.6.
  • Edit line 9 of C:\Users\Student\Documents\Arduino\libraries\esp32_https_server-1.0.0\src/HTTPConnection.hpp with the fix provided by the author of the bug report:

    I suggest replacing

    #include <hwcrypto/sha.h>
    

    with

    #include <sha/sha_parallel_engine.h>
    
2 Likes

thank you!!
now it works.

Its been my first time using a more complex external library. The author is really tryharding on this one. Insane how he tries to cover everything.

Thanks for your help!

You're welcome. I'm glad to hear it's working now!