From 648114fcbe78af9fa6aa74b42a106a4fc4ed1535 Mon Sep 17 00:00:00 2001 From: rodriguezst <2828844+rodriguezst@users.noreply.github.com> Date: Mon, 13 Jun 2022 11:59:42 +0000 Subject: [PATCH] Use textarea instead of input tags for certs --- WebCfgServer.cpp | 32 +++++++++++++++++++++++++++++--- WebCfgServer.h | 1 + networkDevices/WifiDevice.cpp | 6 +++--- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/WebCfgServer.cpp b/WebCfgServer.cpp index adc1448..af24b06 100644 --- a/WebCfgServer.cpp +++ b/WebCfgServer.cpp @@ -452,9 +452,9 @@ void WebCfgServer::buildMqttConfigHtml(String &response) printInputField(response, "MQTTPORT", "MQTT Broker port", _preferences->getInt(preference_mqtt_broker_port), 5); printInputField(response, "MQTTUSER", "MQTT User (# to clear)", _preferences->getString(preference_mqtt_user).c_str(), 30); printInputField(response, "MQTTPASS", "MQTT Password", "*", 30, true); - printInputField(response, "MQTTCA", "MQTT SSL CA Certificate", _preferences->getString(preference_mqtt_ca).c_str(), 180); - printInputField(response, "MQTTCRT", "MQTT SSL Client Certificate", _preferences->getString(preference_mqtt_crt).c_str(), 180); - printInputField(response, "MQTTKEY", "MQTT SSL Client Key", _preferences->getString(preference_mqtt_key).c_str(), 180); + printTextarea(response, "MQTTCA", "MQTT SSL CA Certificate", _preferences->getString(preference_mqtt_ca).c_str(), 1800); + printTextarea(response, "MQTTCRT", "MQTT SSL Client Certificate", _preferences->getString(preference_mqtt_crt).c_str(), 1800); + printTextarea(response, "MQTTKEY", "MQTT SSL Client Key", _preferences->getString(preference_mqtt_key).c_str(), 1800); printInputField(response, "NETTIMEOUT", "Network Timeout until restart (seconds; -1 to disable)", _preferences->getInt(preference_network_timeout), 5); response.concat(""); response.concat("
"); @@ -598,6 +598,32 @@ void WebCfgServer::printCheckBox(String &response, const char *token, const char response.concat("/>"); } +void WebCfgServer::printTextarea(String& response, + const char *token, + const char *description, + const char *value, + const size_t maxLength) +{ + char maxLengthStr[20]; + + itoa(maxLength, maxLengthStr, 10); + + response.concat(""); + response.concat(""); + response.concat(description); + response.concat(""); + response.concat(""); + response.concat(" "); + response.concat(""); + response.concat(""); +} + void WebCfgServer::printParameter(String& response, const char *description, const char *value) { response.concat(""); diff --git a/WebCfgServer.h b/WebCfgServer.h index f8152bf..6d0b4b3 100644 --- a/WebCfgServer.h +++ b/WebCfgServer.h @@ -41,6 +41,7 @@ private: void printInputField(String& response, const char* token, const char* description, const char* value, const size_t maxLength, const bool isPassword = false); void printInputField(String& response, const char* token, const char* description, const int value, size_t maxLength); void printCheckBox(String& response, const char* token, const char* description, const bool value); + void printTextarea(String& response, const char *token, const char *description, const char *value, const size_t maxLength); void printParameter(String& response, const char* description, const char* value); diff --git a/networkDevices/WifiDevice.cpp b/networkDevices/WifiDevice.cpp index cf46cbd..6eee29e 100644 --- a/networkDevices/WifiDevice.cpp +++ b/networkDevices/WifiDevice.cpp @@ -13,14 +13,14 @@ WifiDevice::WifiDevice(const String& hostname, Preferences* _preferences) if(caLength > 1) // length is 1 when empty { Serial.println(F("MQTT over TLS.")); - Serial.print(_ca); + Serial.println(_ca); _wifiClientSecure = new WiFiClientSecure(); _wifiClientSecure->setCACert(_ca); if(crtLength > 1 && keyLength > 1) // length is 1 when empty { Serial.println(F("MQTT with client certificate.")); - Serial.print(_cert); - Serial.print(_key); + Serial.println(_cert); + Serial.println(_key); _wifiClientSecure->setCertificate(_cert); _wifiClientSecure->setPrivateKey(_key); }