Closed
Description
- This issue complies with the issue POLICY doc.
- I have read the documentation at readthedocs and the issue is not addressed there.
- I have tested that the issue is present in current master branch (aka latest git).
- I have searched the issue tracker for a similar issue.
- If there is a stack dump, I have decoded it.
- I have filled out all fields below.
Platform
- Hardware: ESP-12
- Core Version: framework-arduinoespressif8266 3.20701.0 (2.7.1)
- Development Env: Platformio on VSCode
- Operating System: Linux denkfabrik 5.7.2-arch1-1 Update to SDK 1.0.0 #1 SMP PREEMPT Wed, 10 Jun 2020 20:36:24 +0000 x86_64 GNU/Linux
Settings in IDE
- Module: Wemos D1 mini r2
- Flash Mode: (default)
- Flash Size: 4MB
- lwip Variant: (default)
- Reset Method: (default)
- Flash Frequency: 40Mhz
- CPU Frequency: 80Mhz
- Upload Using: SERIAL
- Upload Speed: 115200
Problem Description
Many old (2018) tutorials and articles describe that you can use a root certificate fingerprint to validate your connections. Is it true that BearSSL does not support this? This example shows that.
Expected behavior: Root certificate SHA-1 fingerprints can be used to verify connections.
Rationale: We are living in a world where Let's Encrypt certs are the norm. These have a very short lifetime (90 days). If we can only validate against these, an OTA update of connected devices will be needed all the time or the device needs to be reflashed to regain connectivity, after the cert has been invalidated.
MCVE Sketch
/*
HTTP over TLS (HTTPS) example sketch
*/
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#ifndef STASSID
#define STASSID "ssid"
#define STAPSK "password"
#endif
const char* ssid = STASSID;
const char* password = STAPSK;
const char* host = "api.github.com";
const int httpsPort = 443;
// Use web browser to view and copy
// SHA1 fingerprint of the certificate
// The connection works with this fingerprint (*.github.com direct):
// const char fingerprint[] PROGMEM = "59 74 61 88 13 CA 12 34 15 4D 11 0A C1 7F E6 67 07 69 42 F5";
// It does not work with this fingerprint (root cert)
const char fingerprint[] PROGMEM = "5F B7 EE 06 33 E2 59 DB AD 0C 4C 9A E6 D3 8F 1A 61 C7 DC 25";
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
}
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
// Use WiFiClientSecure class to create TLS connection
WiFiClientSecure client;
Serial.print("connecting to ");
Serial.println(host);
Serial.printf("Using fingerprint '%s'\n", fingerprint);
client.setFingerprint(fingerprint);
// Setting insecure disables the fingerprint verification.
//client.setInsecure();
if (!client.connect(host, httpsPort)) {
Serial.println("connection failed");
} else {
Serial.println("secure connection established");
}
}
void loop() {
}