Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure does not survive PKI keys #678

Closed
jhps opened this issue Oct 1, 2024 · 1 comment · Fixed by #696
Closed

configure does not survive PKI keys #678

jhps opened this issue Oct 1, 2024 · 1 comment · Fixed by #696

Comments

@jhps
Copy link

jhps commented Oct 1, 2024

In 2.5 (65305af), a configuration that has privateKey, publicKey, or adminKeys causes the cli to exit with:
Aborting due to: expected bytes, str found

It seems that MessageToDict() converts bytes to base64 strings that are saved in the config yaml but when these are are later loaded into a config to be sent a setattr() of a string to a bytes field causes an exception.

@contra-bit
Copy link

contra-bit commented Oct 9, 2024

I'd like to mention that also the Python CLI has an issue with serializing public keys, which always converts them to a string or bytes, regardless of the input format. This should be fixed to ensure consistent behavior.

Fixes:

  • Fix the Python CLI issue with serializing public keys.

All of these examples produce the same error.

meshtastic --set security.is_managed true --set security.admin_key b'XXXXXXXXXXXXXXXXXXXXXXXXXX' --set security.admin_channel_enabled true
meshtastic --set security.is_managed true --set security.admin_key XXXXXXXXXXXXXXXXXXXXXXXXXX --set security.admin_channel_enabled true
meshtastic --set security.is_managed true --set security.admin_key 'XXXXXXXXXXXXXXXXXXXXXXXXXX' --set security.admin_channel_enabled true

In the example with: b'XXXXXXXXXXXXXXXXXXXXXXXXXX' it tries to add the b to the bytes

The fix should also document how to add multiple admin keys as per meshtastic/web#315

fmoessbauer added a commit to fmoessbauer/meshtastic-python that referenced this issue Oct 18, 2024
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: meshtastic#678
fmoessbauer added a commit to fmoessbauer/meshtastic-python that referenced this issue Oct 18, 2024
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: meshtastic#678
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants