Hello everyone! I'm working on a project that sets up a Flask-based web server on an ngrok endpoint, allowing Internet access. The goal is to serve static files (JSON and binary) to manage OTA updates on ESP32 microcontrollers.
I've successfully deployed my Flask application using the free-tier ngrok static domain. I can access it on both my cellphone and computer without any issues. I also managed to serve a JSON file containing firmware version information for managing update requests from the ESP32. However, I encounter SSL certificate errors when trying to access the static domain via an HTTPClient instance on the microcontroller. The error occurs when this function is called:
Instead of retrieving the firmware version, I receive a connection error (line 29):
This code was written using the Arduino framework on PlatformIO. It's also worth mentioning that the required SSL certificates are already included in my code (as a
I've successfully deployed my Flask application using the free-tier ngrok static domain. I can access it on both my cellphone and computer without any issues. I also managed to serve a JSON file containing firmware version information for managing update requests from the ESP32. However, I encounter SSL certificate errors when trying to access the static domain via an HTTPClient instance on the microcontroller. The error occurs when this function is called:
C++:
float getFirmwareVFromServer(const char* url) {
HTTPClient http;
WiFiClientSecure client;
client.setCACert(root_ca);
http.begin(client, url);
int httpCode = http.GET();
float version = 0.0;
if (httpCode > 0) {
if (httpCode == HTTP_CODE_OK) {
String payload = http.getString();
Serial.println("Update Info: " + payload);
const size_t capacity = JSON_OBJECT_SIZE(2) + 60;
DynamicJsonDocument doc(capacity);
DeserializationError error = deserializeJson(doc, payload);
if (!error) {
version = doc["last-firmware-v"].as<float>();
} else {
Serial.print("JSON deserialization failed: ");
Serial.println(error.f_str());
}
} else {
Serial.printf("HTTP GET failed, error: %s\n", http.errorToString(httpCode).c_str());
}
} else {
Serial.printf("Unable to connect, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end();
return version;
}
Error messages printed on Serial Monitor:
[ 7124][E][ssl_client.cpp:37] _handle_error(): [start_ssl_client():273]: (-29312) SSL - The connection indicated an EOF
[ 7124][E][WiFiClientSecure.cpp:144] connect(): start_ssl_client: -29312
Unable to connect, error: connection refused
const char*
declared with the name root_ca
). However, the server is not allowing the connection to be established. Any advice on resolving this SSL issue would be greatly appreciated!