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

Add ipfs cli 'rotate' command to rotate identity private keys #7515

Merged
merged 2 commits into from
Jul 15, 2020

Conversation

petar
Copy link
Contributor

@petar petar commented Jun 30, 2020

No description provided.

@petar petar requested a review from aschmahmann June 30, 2020 23:40
@welcome
Copy link

welcome bot commented Jun 30, 2020

Thank you for submitting this PR!
A maintainer will be here shortly to review it.
We are super grateful, but we are also overloaded! Help us by making sure that:

  • The context for this PR is clear, with relevant discussion, decisions
    and stakeholders linked/mentioned.

  • Your contribution itself is clear (code comments, self-review for the
    rest) and in its best form. Follow the code contribution
    guidelines

    if they apply.

Getting other community members to do a review would be great help too on complex PRs (you can ask in the chats/forums). If you are unsure about something, just leave us a comment.
Next steps:

  • A maintainer will triage and assign priority to this PR, commenting on
    any missing things and potentially assigning a reviewer for high
    priority items.

  • The PR gets reviews, discussed and approvals as needed.

  • The PR is merged by maintainers when it has been approved and comments addressed.

We currently aim to provide initial feedback/triaging within two business days. Please keep an eye on any labelling actions, as these will indicate priorities and status of your contribution.
We are very grateful for your contribution!

Copy link
Contributor

@aschmahmann aschmahmann left a comment

Choose a reason for hiding this comment

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

Added a few small suggestions. We should also add some tests for this. The general way we do this is by adding additional sharness tests (https://github.com/ipfs/go-ipfs/tree/master/test/sharness).

At least one test we should probably do is:

  • Create repo + run daemon
  • Kill daemon
  • Rotate keys
  • Rerun the daemon
  • Check ipfs id output to verify the ID has changed
  • Check ipfs key self output to make sure key has changed
  • Check ipfs key list -l to check if the rotated key has the correct ID
  • Do an ipfs name publish --key=rotatedKey, just to make sure it works

cmd/ipfs/rotate.go Outdated Show resolved Hide resolved
cmd/ipfs/rotate.go Outdated Show resolved Hide resolved
cmd/ipfs/rotate.go Outdated Show resolved Hide resolved
cmd/ipfs/rotate.go Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
Copy link
Contributor

@aschmahmann aschmahmann left a comment

Choose a reason for hiding this comment

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

LGTM. Although we probably want to block approval of this PR on #7251 for now. If that PR stalls then we can make this PR default to RSA and modify #7251 to compensate.

@aschmahmann aschmahmann added the status/blocked Unable to be worked further until needs are met label Jul 2, 2020
Copy link
Contributor

@aschmahmann aschmahmann left a comment

Choose a reason for hiding this comment

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

This PR is good to go. If we switch the default rotation to RSA and maybe use functions in the test to test RSA + Ed25519 + defaults.

Comment on lines 18 to 20
test_expect_success "rotating keys" '
ipfs rotate --oldkey=oldkey
'
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should put this in a function like you did in the init PR, so we can verify RSA, Ed25519 and the default all work.

@petar
Copy link
Contributor Author

petar commented Jul 14, 2020

This PR is good to go. If we switch the default rotation to RSA and maybe use functions in the test to test RSA + Ed25519 + defaults.

Default RSA will work awkwardly with the new strict rule that requires not specifying bits when using ed25519: If you set the defaults to RSA+2048, then whenever you want to use --algorithm=ed25519 you don't have a way of unsetting the number of bits flag.

Maybe best is if rotation has NO default?

@aschmahmann
Copy link
Contributor

Having a default is fine. Can't we just have the defaults to mimic what we have in init where we default to an algorithm but no bits, and only pass the bits into config.Identity when they're specified?

@petar
Copy link
Contributor Author

petar commented Jul 14, 2020

Having a default is fine. Can't we just have the defaults to mimic what we have in init where we default to an algorithm but no bits, and only pass the bits into config.Identity when they're specified?

Sure. This works too.

test/sharness/lib/test-lib.sh Outdated Show resolved Hide resolved
test/sharness/t0027-rotate.sh Outdated Show resolved Hide resolved
Comment on lines +8 to +9
FROM_ALG=$1
TO_ALG=$2
Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine, although I think we can simplify it so that we:

  1. first test basic rotation on default, RSA, Ed25519 using the test_rotate function which indicates that rotation basically works
  2. test rotating Ed25519 -> RSA -> Ed25519 which indicates that we can rotate to/from each key type. We can even use test_expect_success for these steps to make them easier to debug/notice.

@aschmahmann aschmahmann merged commit 3d3c036 into master Jul 15, 2020
@aschmahmann aschmahmann mentioned this pull request Sep 22, 2020
72 tasks
@hacdias hacdias deleted the petar/rollover branch May 9, 2023 10:59
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.

2 participants