Is there an Arduino ESP32 that supports TLS 1.3? #11105
Replies: 4 comments
-
I forgot to mention that I'm using esp32 by Espressif System library, the version I'm using is 3.0.3 |
Beta Was this translation helpful? Give feedback.
-
I found that https://github.com/govorox/SSLClient is based on Based on Mbed-TLS/mbedtls. I'm still getting TLS 1.2 when making get request to www.howsmyssl.com. Making GET request... |
Beta Was this translation helpful? Give feedback.
-
I'm now using the GovoroxSSLClient (v 1.3.2), the ESP32 by Espressif Systems (v 3.0.3), the ArduinoHTTPClient (v 0.6.1) libraries. Making POST request... Here is my code: #include "ca_cert.h" // Include the header file with the certificate // Replace these with your Wi-Fi credentials // Update with your endpoint hostname // Layers stack void setup() { // Connect to Wi-Fi // Add CA Certificate void loop() { // Prepare POST request payload // Set request headers and payload // Send payload // Read response Serial.print("Status code: "); http_client.stop(); delay(30000); |
Beta Was this translation helpful? Give feedback.
-
Now I have a successful POST request. Ensure that the hostname is correctly set and does not include the protocol (https://). The hostname should only be the domain part of the URL. The endPointURL should be the path part of the URL, without the leading /. In this case, it's correct. |
Beta Was this translation helpful? Give feedback.
-
Board
ESP32
Device Description
I want to connect my ESP32 to an Oracle Apex Resftul service,
With the code below, I'm getting "Error on sending POST: -11".
I read that the ESP32 Arduino Code library only supports TLS 1.2, but Oracle Apex Restful service is using TLS 1.3.
By any chance, do you know if there is an ESP32 Arduino library that supports TLS 1.3?
Code
#include <WiFi.h>
#include <HTTPClient.h>
#include <WiFiClientSecure.h>
// Replace these with your network credentials
const char* ssid = "YOUR_SSID";
const char* password = "YOUR PASSWORD";
// Replace these with your Oracle APEX endpoint details
const char* endpointUrl = "https://apex.oracle.com/pls/apex/ccarrillo/ultrasonicsensor/insert_data";
// CA certificate of the server
const char* rootCACertificate =
"-----BEGIN CERTIFICATE-----\n"
"MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh\n"
"MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRk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qDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls\n"
"YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk\n"
"CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=\n"
"-----END CERTIFICATE-----\n";
// Ultrasonic sensor variables
const int trigPin = 13;
const int echoPin = 12;
#define SOUND_SPEED 0.034 // define sound speed in cm/uS
float globalDistanceCm;
void setup() {
Serial.begin(115200);
// Connecting to WiFi
setupWiFi();
// Initializing pins for the ultrasonic sensor
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
}
void loop() {
globalDistanceCm = getDistance();
// Prints the distance in the Serial Monitor
Serial.print("Distance (cm): ");
Serial.println(globalDistanceCm);
sendData(globalDistanceCm);
delay(5000);
}
void setupWiFi() {
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(".");
}
Serial.println("Connected to Wi-Fi");
}
float getDistance() {
long duration;
float distanceCm;
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculate the distance
distanceCm = duration * SOUND_SPEED / 2;
return distanceCm;
}
// Function to send data
void sendData(float sensorValue) {
WiFiClientSecure client;
HTTPClient http;
client.setCACert(rootCACertificate);
if (!client.connect("apex.oracle.com", 443)) {
Serial.println("Connection failed!");
return;
}
http.begin(client, endpointUrl);
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
// Create the POST request payload
String payload = "sensor_value=" + String(sensorValue, 2);
int httpResponseCode = http.POST(payload);
// Check and print the response
if (httpResponseCode > 0) {
String response = http.getString();
Serial.println(httpResponseCode);
Serial.println(response);
} else {
Serial.print("Error on sending POST: ");
Serial.println(httpResponseCode);
}
http.end();
}
Hardware Configuration
Version
v3.0.3
IDE Name
Arduino IDE 2.3.2
Operating System
Windows 10
Flash frequency
N/A
PSRAM enabled
yes
Upload speed
115200
Description
I want to connect my ESP32 to an Oracle Apex Resftul service,
With the code below, I'm getting "Error on sending POST: -11".
I read that the ESP32 Arduino Code library only supports TLS 1.2, but Oracle Apex Restful service is using TLS 1.3.
By any chance, do you know if there is an ESP32 Arduino library that supports TLS 1.3?
Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
Beta Was this translation helpful? Give feedback.
All reactions