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

feat: allow key export in online mode #8113

Merged
merged 4 commits into from
May 12, 2021
Merged

Conversation

lidel
Copy link
Member

@lidel lidel commented May 7, 2021

This PR enables apps like Brave browser to do import/export without stopping/starting daemon.

Export does not require repo lock, and afaik it is safe to do even when ipfs daemon is running.

Ref. brave/brave-browser#15422 (cc @spylogsster)

Export does not require repo lock and it is safe to do even when ipfs
daemon is running. This enables apps like Brave browser to do
import/export without stopping/starting daemon.

Ref. brave/brave-browser#15422
@lidel lidel added this to the go-ipfs 0.9 milestone May 7, 2021
Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable but let's do a few more checks.

test/sharness/t0165-keystore.sh Show resolved Hide resolved
core/commands/keystore.go Show resolved Hide resolved
@@ -150,7 +151,6 @@ path can be specified with '--output=<path>' or '-o=<path>'.
cmds.StringOption(outputOptionName, "o", "The path where the output should be stored."),
},
NoRemote: true,
PreRun: DaemonNotRunning,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this check is probably fine, but mostly as a function of the keystore currently living on the filesystem and hoping that Go + the OS properly obey filesystem semantics cross platform. If we try and move keystore into some database this could start to fall apart since the database might require a single access point.

As for the keeping the keys on the filesystem, I'm not really a fan, especially since they're currently unencrypted (although that's fairly fixable), so even though it's low on the priority list it'd be a nice thing to deal with. This is especially so because we have no way of revoking IPNS keys (although setting the sequence number to the max value might do the job) or pushing people onto new keys if the old ones are compromised. Thus far IPNS has not had super high usage due to performance issues but as those resolve (IPNS over PubSub, faster DHT lookups, etc.) the idea of protecting the keys better may come into focus.

Are we ok either boxing ourselves into using a keystore that is always readable by multiple processes, or with having online key export potentially not be available in the future?

cc @Stebalien @lidel

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I think we should be able to do this without boxing ourselves into a corner. We'd probably need something in the future that:

  1. Reads the config to find where the keys are actually stored.
  2. Possibly connects to the system keyring.

For now, the current code is likely fine. In the future, we'll likely need something to open a keystore without opening the rest of the repo (i.e., read the config to find where the keystore is, then read the keystore). Some keystores may not support this, but that's fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it'll be a bit more complicated but it seems doable enough for us to go ahead with this now. Some things we may have to worry about are:

  • making sure to control how the config fine is modified if it has keystone info in there
  • checking the keystone type and for some of them returning something like "error cannot export keys from this keystone while the daemon is running"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. That means checking the repo version is going to be important.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added version check in 6b63de8

@lidel
Copy link
Member Author

lidel commented May 11, 2021

Added more tests and repo version check.
Ready for final review.

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit, otherwise LGTM.

Any objections @aschmahmann?

core/commands/keystore.go Outdated Show resolved Hide resolved
@aschmahmann aschmahmann merged commit c824855 into master May 12, 2021
@lidel lidel deleted the feat/key-export-online branch May 13, 2021 16:33
@aschmahmann aschmahmann mentioned this pull request May 14, 2021
71 tasks
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 this pull request may close these issues.

3 participants