Hola
Mi nodeMCU8266 se conecta a un fichero PHP ubicado en una web https. Este fichero realiza varias query y devuelve (con un Echo, un resultado)
Ayer se ha caducado el certificado Let's Encrypt de mi web, y el Fingerprint ha cambiado. El resultado es que el NodeMCU ya no puede conectarse y tengo que ir yo a mano a cambiarselo (ya está instalado en una puerta automática)
Queria preguntar si hay alguna solución alternativa ya que de esta manera cada 3 meses tendré que ir a actualizar a mano el arduino.
El trozo de código es este
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClientSecureBearSSL.h>
#include <Keypad.h>
const char *ssid = "XXXXXX"; //ENTER YOUR WIFI SETTINGS
const char *password = "XXXX";
const char *host = "aaa.com";
const int httpsPort = 443; //HTTPS= 443 and HTTP = 80
//certificado de aaa.com
const char fingerprint[] PROGMEM = "3B DD 09 22 BD 2B 5C 3D 61 C0 47 0A FE 85 50 18 B1 8E C6 3C";
WiFiClientSecure httpsClient;
//Serial.println(host);
//Serial.printf("Using fingerprint '%s'\n", fingerprint);
httpsClient.setFingerprint(fingerprint);
httpsClient.setTimeout(15000); // 15 Seconds
//delay(1000);
//Serial.print("HTTPS Connecting");
int r=0; //retry counter
while((!httpsClient.connect(host, httpsPort)) && (r < 30)){
delay(100);
Serial.print(".");
r++;
}
if(r==30) {
Serial.println("Connection failed");
}
else {
Serial.println("Connected to web");
}
String code, Link;
int i;
for (i = 0; i < 6; i++) {
code = code + codigo[i];
}
Link = "/file.php?aid=" + code;
Serial.print("requesting URL: ");
Serial.println(host+Link);
httpsClient.print(String("GET ") + Link + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
Serial.println("request sent");
while (httpsClient.connected()) {
String line = httpsClient.readStringUntil('\n');
if (line == "\r") {
Serial.println("headers received");
break;
}
}
Serial.println("reply was:");
String line;
while(httpsClient.available()){
line = httpsClient.readStringUntil('\n'); //Read Line by Line
Serial.println(line); //Print response
}