From e17ee6168e0879878d88c04197ae40025e0c0f89 Mon Sep 17 00:00:00 2001 From: Niek van der Maas Date: Tue, 22 Oct 2019 16:08:15 +0200 Subject: [PATCH] MQTT & OTA Fingerprint setting capitalization fix (#1952) * MQTT Fingerprint setting capitalization fix * otafp -> otaFP --- code/espurna/mqtt.ino | 4 ++-- code/espurna/ota_asynctcp.ino | 5 ++++- code/espurna/ota_httpupdate.ino | 9 ++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/code/espurna/mqtt.ino b/code/espurna/mqtt.ino index 65863e00..d5777e0b 100644 --- a/code/espurna/mqtt.ino +++ b/code/espurna/mqtt.ino @@ -102,7 +102,7 @@ SecureClientConfig _mqtt_sc_config { return getSetting("mqttScCheck", MQTT_SECURE_CLIENT_CHECK).toInt(); }, []() -> String { - return getSetting("mqttfp", MQTT_SSL_FINGERPRINT); + return getSetting("mqttFP", MQTT_SSL_FINGERPRINT); }, true }; @@ -118,7 +118,7 @@ SecureClientConfig _mqtt_sc_config { return _mqtt_client_trusted_root_ca; }, []() -> String { - return getSetting("mqttfp", MQTT_SSL_FINGERPRINT); + return getSetting("mqttFP", MQTT_SSL_FINGERPRINT); }, []() -> uint16_t { return getSetting("mqttScMFLN", MQTT_SECURE_CLIENT_MFLN).toInt(); diff --git a/code/espurna/ota_asynctcp.ino b/code/espurna/ota_asynctcp.ino index e01ca236..a03fa2cb 100644 --- a/code/espurna/ota_asynctcp.ino +++ b/code/espurna/ota_asynctcp.ino @@ -101,7 +101,7 @@ void _otaClientOnConnect(void *arg, AsyncClient *client) { int check = getSetting("otaScCheck", OTA_SECURE_CLIENT_CHECK).toInt(); if ((check == SECURE_CLIENT_CHECK_FINGERPRINT) && (443 == _ota_url->port)) { uint8_t fp[20] = {0}; - sslFingerPrintArray(getSetting("otafp", OTA_FINGERPRINT).c_str(), fp); + sslFingerPrintArray(getSetting("otaFP", OTA_FINGERPRINT).c_str(), fp); SSL * ssl = _ota_client->getSSL(); if (ssl_match_fingerprint(ssl, fp) != SSL_OK) { DEBUG_MSG_P(PSTR("[OTA] Warning: certificate fingerpint doesn't match\n")); @@ -214,6 +214,9 @@ void _otaClientMqttCallback(unsigned int type, const char * topic, const char * void otaClientSetup() { + // Backwards compatibility + moveSetting("otafp", "otaFP"); + #if TERMINAL_SUPPORT _otaClientInitCommands(); #endif diff --git a/code/espurna/ota_httpupdate.ino b/code/espurna/ota_httpupdate.ino index 6cb2b49a..0588cfc4 100644 --- a/code/espurna/ota_httpupdate.ino +++ b/code/espurna/ota_httpupdate.ino @@ -111,9 +111,9 @@ void _otaClientFromHttps(const String& url) { } if (check == SECURE_CLIENT_CHECK_FINGERPRINT) { - String fp_string = getSetting("otafp", OTA_FINGERPRINT); + String fp_string = getSetting("otaFP", OTA_FINGERPRINT); if (!fp_string.length()) { - DEBUG_MSG_P(PSTR("[OTA] Requested fingerprint auth, but 'otafp' is not set\n")); + DEBUG_MSG_P(PSTR("[OTA] Requested fingerprint auth, but 'otaFP' is not set\n")); return; } @@ -166,7 +166,7 @@ void _otaClientFromHttps(const String& url) { String fp_string; if (check == SECURE_CLIENT_CHECK_FINGERPRINT) { - fp_string = getSetting("otafp", OTA_FINGERPRINT); + fp_string = getSetting("otaFP", OTA_FINGERPRINT); if (!fp_string.length() || !sslCheckFingerPrint(fp_string.c_str())) { DEBUG_MSG_P(PSTR("[OTA] Wrong fingerprint\n")); return; @@ -250,6 +250,9 @@ void _otaClientMqttCallback(unsigned int type, const char * topic, const char * void otaClientSetup() { + // Backwards compatibility + moveSetting("otafp", "otaFP"); + #if TERMINAL_SUPPORT _otaClientInitCommands(); #endif