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

If file given with nkeys_seed parameter contains a newline, the nkeys.from_seed() fails with nkeys: invalid seed #417

Open
JarleB opened this issue Jan 31, 2023 · 1 comment

Comments

@JarleB
Copy link

JarleB commented Jan 31, 2023

When using the nk utility as described in https://docs.nats.io/running-a-nats-service/configuration/securing_nats/auth_intro/nkey_auth#generating-nkeys-and-configuring-the-server it seems ok to cut/paste the seed into a file and load it with the nkeys_seed parameter of nats.py. However, most editors (and shell redirect) will add a newline at the end of the seed, and that will make nkeys.from_seed() in https://github.com/nats-io/nats.py/blob/main/nats/aio/client.py#L515 fail with nkeys: invalid seed . This could be more robust if the file reading included a stripping of whitespace at end of line before decoding and turning it into a bytearray

In order for nats.py to work with user nkeys generated with the nk utility the file could be generated like this:

printf "%s" $(nk -gen user) > file

And to get the pubkey for using in the server config:

nk -pubout -inkey file

Perhaps the file loading code behind the nkeys_seed parameter could sanitize the file before load ?

@aohan237
Copy link

#426 just add a strip line will do this work

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

No branches or pull requests

2 participants