[MQTT TLS] Disable PSK option

This commit is contained in:
TD-er
2024-09-30 09:14:55 +02:00
parent e28505bada
commit 9bca93b358
5 changed files with 17 additions and 20 deletions
@@ -335,14 +335,16 @@ String ControllerSettingsStruct::getCertificateFilename(TLS_types tls_type) cons
case TLS_types::NoTLS:
case TLS_types::TLS_insecure:
return EMPTY_STRING;
/*
case TLS_types::TLS_PSK:
certFile += F(".psk");
break;
/*
*/
/*
case TLS_types::TLS_CA_CLI_CERT:
certFile += F(".caclicert");
break;
*/
*/
case TLS_types::TLS_CA_CERT:
certFile += F(".cacert");
break;
+1 -1
View File
@@ -5,7 +5,7 @@ const __FlashStringHelper* toString(TLS_types tls_type)
{
switch (tls_type) {
case TLS_types::NoTLS: break;
case TLS_types::TLS_PSK: return F("TLS PreSharedKey");
// case TLS_types::TLS_PSK: return F("TLS PreSharedKey");
case TLS_types::TLS_CA_CERT: return F("TLS CA Cert");
case TLS_types::TLS_insecure: return F("TLS No Checks (insecure)");
case TLS_types::TLS_FINGERPRINT: return F("TLS Certficate Fingerprint");
+1 -1
View File
@@ -10,7 +10,7 @@
// Value is stored, so do not change assigned integer values.
enum class TLS_types {
NoTLS = 0, // Do not use encryption
TLS_PSK = 1, // Pre-Shared-Key
// TLS_PSK = 1, // Pre-Shared-Key
TLS_CA_CERT = 2, // Validate server certificate against known CA
//TLS_CA_CLI_CERT = 3, // TLS_CA_CERT + supply client certificate for authentication
TLS_FINGERPRINT = 4, // Use certificate fingerprint
+2
View File
@@ -256,12 +256,14 @@ bool MQTTConnect(controllerIndex_t controller_idx)
MQTTclient.setClient(mqtt);
break;
}
/*
case TLS_types::TLS_PSK:
{
// if (mqtt_tls != nullptr)
// mqtt_tls->setPreSharedKey(const char *pskIdent, const char *psKey); // psKey in Hex
break;
}
*/
case TLS_types::TLS_CA_CERT:
{
mqtt_rootCA.clear();
+9 -16
View File
@@ -187,43 +187,37 @@ void addControllerParameterForm(const ControllerSettingsStruct& ControllerSettin
#if FEATURE_MQTT_TLS
case ControllerSettingsStruct::CONTROLLER_MQTT_TLS_TYPE:
{
#if FEATURE_MQTT_TLS
const int choice = static_cast<int>(ControllerSettings.TLStype());
#define NR_MQTT_TLS_TYPES 4
const __FlashStringHelper * options[NR_MQTT_TLS_TYPES] = {
toString(TLS_types::NoTLS),
const __FlashStringHelper * options[] = {
toString(TLS_types::NoTLS),
// toString(TLS_types::TLS_PSK),
toString(TLS_types::TLS_CA_CERT),
toString(TLS_types::TLS_FINGERPRINT),
toString(TLS_types::TLS_insecure)
toString(TLS_types::TLS_CA_CERT),
toString(TLS_types::TLS_FINGERPRINT),
toString(TLS_types::TLS_insecure)
};
const int indices[NR_MQTT_TLS_TYPES] = {
const int indices[] = {
static_cast<int>(TLS_types::NoTLS),
// static_cast<int>(TLS_types::TLS_PSK),
static_cast<int>(TLS_types::TLS_CA_CERT),
static_cast<int>(TLS_types::TLS_FINGERPRINT),
static_cast<int>(TLS_types::TLS_insecure)
};
addFormSelector(displayName, internalName, NR_MQTT_TLS_TYPES, options, indices, choice, true);
#undef NR_MQTT_TLS_TYPES
addCertificateFileNote(ControllerSettings, F("Certificate or PSK must be stored on the filesystem in"), ControllerSettings.TLStype());
#endif
constexpr int nrOptions = NR_ELEMENTS(indices);
addFormSelector(displayName, internalName, nrOptions, options, indices, choice, true);
addCertificateFileNote(ControllerSettings, F("Certificate or FingerPrint must be stored on the filesystem in"), ControllerSettings.TLStype());
break;
}
case ControllerSettingsStruct::CONTROLLER_MQTT_TLS_STORE_FINGERPRINT:
{
#if FEATURE_MQTT_TLS
const bool saveDisabled = fileExists(ControllerSettings.getCertificateFilename(TLS_types::TLS_FINGERPRINT));
addFormCheckBox(displayName, internalName, false, saveDisabled);
addCertificateFileNote(ControllerSettings, F("Store fingerprint in"), TLS_types::TLS_FINGERPRINT);
#endif
break;
}
case ControllerSettingsStruct::CONTROLLER_MQTT_TLS_STORE_CERT:
// fall through
case ControllerSettingsStruct::CONTROLLER_MQTT_TLS_STORE_CACERT:
{
#if FEATURE_MQTT_TLS
/*
const TLS_types tls_type = (varType == ControllerSettingsStruct::CONTROLLER_MQTT_TLS_STORE_CACERT) ?
TLS_types::TLS_CA_CERT : TLS_types::TLS_CERT;
@@ -234,7 +228,6 @@ void addControllerParameterForm(const ControllerSettingsStruct& ControllerSettin
addUnit(F("File Exists"));
}
addCertificateFileNote(ControllerSettings, F("Store CA Certificate in"), TLS_types::TLS_CA_CERT);
#endif
break;
}
#endif