adding ssl fingerprint verification to comply with bearssl in esp8266 bsp 2.5.1

This commit is contained in:
brentru 2019-05-20 11:20:45 -04:00
parent bfdece49f7
commit d5aa959525
2 changed files with 3 additions and 31 deletions

View File

@ -44,7 +44,7 @@ WiFiClientSecure client;
Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY);
// io.adafruit.com SHA1 fingerprint
const char *fingerprint = "77 00 54 2D DA E7 D8 03 27 31 23 99 EB 27 DB CB A5 4C 57 18";
static const char *fingerprint PROGMEM = "77 00 54 2D DA E7 D8 03 27 31 23 99 EB 27 DB CB A5 4C 57 18";
/****************************** Feeds ***************************************/
@ -54,11 +54,6 @@ Adafruit_MQTT_Publish test = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/t
/*************************** Sketch Code ************************************/
// Bug workaround for Arduino 1.6.6, it seems to need a function declaration
// for some reason (only affects ESP8266, likely an arduino-builder bug).
void MQTT_connect();
void verifyFingerprint();
void setup() {
Serial.begin(115200);
delay(10);
@ -85,8 +80,7 @@ void setup() {
Serial.println("IP address: "); Serial.println(WiFi.localIP());
// check the fingerprint of io.adafruit.com's SSL cert
verifyFingerprint();
client.setFingerprint(fingerprint);
}
uint32_t x=0;
@ -112,28 +106,6 @@ void loop() {
}
void verifyFingerprint() {
const char* host = AIO_SERVER;
Serial.print("Connecting to ");
Serial.println(host);
if (! client.connect(host, AIO_SERVERPORT)) {
Serial.println("Connection failed. Halting execution.");
while(1);
}
if (client.verify(fingerprint, host)) {
Serial.println("Connection secure.");
} else {
Serial.println("Connection insecure! Halting execution.");
while(1);
}
}
// Function to connect and reconnect as necessary to the MQTT server.
// Should be called in the loop function and it will take care if connecting.
void MQTT_connect() {

View File

@ -1,5 +1,5 @@
name=Adafruit MQTT Library
version=1.0.1
version=1.0.2
author=Adafruit
maintainer=Adafruit <info@adafruit.com>
sentence=MQTT library that supports the FONA, ESP8266, Yun, and generic Arduino Client hardware.