Skip to content

Commit 9ce7a5b

Browse files
committed
fix base64 encoding of key field in config
The security.privateKey and security.publicKey fields are of type bytes, but the protobuf MessageToDict converts them to base64 encoded strings. When importing the config again, this is read as a string, which breaks the import. Instead, the value needs to be prefixed with "base64:", so the type handling logic on import kicks in and decodes the value to a bytes array again. Fixes: #678
1 parent da7fa31 commit 9ce7a5b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: meshtastic/__main__.py

+6
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,12 @@ def export_config(interface):
10341034
prefs[meshtastic.util.snake_to_camel(pref)] = config[pref]
10351035
else:
10361036
prefs[pref] = config[pref]
1037+
# mark base64 encoded fields as such
1038+
if pref == "security":
1039+
if 'privateKey' in prefs[pref]:
1040+
prefs[pref]['privateKey'] = 'base64:' + prefs[pref]['privateKey']
1041+
if 'publicKey' in prefs[pref]:
1042+
prefs[pref]['publicKey'] = 'base64:' + prefs[pref]['publicKey']
10371043
if mt_config.camel_case:
10381044
configObj["config"] = config
10391045
else:

0 commit comments

Comments
 (0)