Use textarea instead of input tags for certs
This commit is contained in:
@@ -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("</table>");
|
||||
response.concat("<br><INPUT TYPE=SUBMIT NAME=\"submit\" VALUE=\"Save\">");
|
||||
@@ -598,6 +598,32 @@ void WebCfgServer::printCheckBox(String &response, const char *token, const char
|
||||
response.concat("/></td></tr>");
|
||||
}
|
||||
|
||||
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("<tr>");
|
||||
response.concat("<td>");
|
||||
response.concat(description);
|
||||
response.concat("</td>");
|
||||
response.concat("<td>");
|
||||
response.concat(" <TEXTAREA NAME=\"");
|
||||
response.concat(token);
|
||||
response.concat("\" MAXLENGTH=\"");
|
||||
response.concat(maxLengthStr);
|
||||
response.concat("\\\">");
|
||||
response.concat(value);
|
||||
response.concat("</TEXTAREA>");
|
||||
response.concat("</td>");
|
||||
response.concat("</tr>");
|
||||
}
|
||||
|
||||
void WebCfgServer::printParameter(String& response, const char *description, const char *value)
|
||||
{
|
||||
response.concat("<tr>");
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user