Rather than mysteriously rebooting, regenerate the keys and infrom the user. (#7558)

This commit is contained in:
Jonathan Bennett
2025-08-05 19:53:25 -05:00
committed by GitHub
parent 384436e937
commit 27c6b24e3a
5 changed files with 70 additions and 119 deletions

View File

@@ -727,7 +727,7 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
}
#endif
config.lora = c.payload_variant.lora;
// If we're setting region for the first time, init the region
// If we're setting region for the first time, init the region and regenerate the keys
if (isRegionUnset && config.lora.region > meshtastic_Config_LoRaConfig_RegionCode_UNSET) {
if (!owner.is_licensed) {
bool keygenSuccess = false;
@@ -772,8 +772,7 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
if (config.security.private_key.size != 32) {
crypto->generateKeyPair(config.security.public_key.bytes, config.security.private_key.bytes);
} else if (config.security.public_key.size != 32) {
// We check for a potentially valid private key, and a blank public key, and regen the public key if needed.
} else {
if (crypto->regeneratePublicKey(config.security.public_key.bytes, config.security.private_key.bytes)) {
config.security.public_key.size = 32;
}