Skip to content

[ca/manager] Stop encrypting the raft root CA key based on env vars#2552

Closed
cyli wants to merge 1 commit into
moby:masterfrom
cyli:remove-root-ca-key-encryption
Closed

[ca/manager] Stop encrypting the raft root CA key based on env vars#2552
cyli wants to merge 1 commit into
moby:masterfrom
cyli:remove-root-ca-key-encryption

Conversation

@cyli
Copy link
Copy Markdown
Contributor

@cyli cyli commented Mar 10, 2018

This feature was never documented nor advertised, and was deprecated almost a year ago. So remove support for encrypting and rotating the root CA key KEK (key-encrypting-key), and only support decrypting the root CA key, if it's encrypted.

This removes some useless code and extra complexity from the manager and the ca package.

@cyli cyli changed the title Stop encrypting the raft root CA key based on env vars ca/manager: Stop encrypting the raft root CA key based on env vars Mar 10, 2018
@cyli cyli changed the title ca/manager: Stop encrypting the raft root CA key based on env vars [ca/manager] Stop encrypting the raft root CA key based on env vars Mar 10, 2018
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 10, 2018

Codecov Report

Merging #2552 into master will increase coverage by 0.04%.
The diff coverage is 94.44%.

@@            Coverage Diff             @@
##           master    #2552      +/-   ##
==========================================
+ Coverage    61.4%   61.44%   +0.04%     
==========================================
  Files          49      133      +84     
  Lines        6332    21729   +15397     
==========================================
+ Hits         3888    13352    +9464     
- Misses       2067     6938    +4871     
- Partials      377     1439    +1062

@cyli cyli force-pushed the remove-root-ca-key-encryption branch from 030fa00 to e532f43 Compare March 14, 2018 22:24
@cyli
Copy link
Copy Markdown
Contributor Author

cyli commented Mar 14, 2018

This will also make it easier and cleaner to implement the change where we remove the GOFIPS env var and inject a bool instead (see #2544), since this is at least one less place where that bool has to be injected. So apologies for pestering you @anshulpundir , but could you have a look? I'd love to rebase my other FIPS PRs on this one, particularly the one that removes the FIPS env var because I think that is causing spurious CI failures because the tests run in parallel, and the env is set for all of them at once. :D

Copy link
Copy Markdown
Collaborator

@dperny dperny left a comment

Choose a reason for hiding this comment

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

Not your fault, but something about this diff makes it super hard to parse. I've reviewed as best as I can and it LGTM, but I would like some more comments in the noted place if you don't mind. Not a blocker though.

Comment thread ca/certificates_test.go Outdated
}

func TestNewRootCA(t *testing.T) {
// even if root encryption passphrases are set, they are not used
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what does this mean? can you add some more comments explaining what this accomplishes and tests?

@cyli
Copy link
Copy Markdown
Contributor Author

cyli commented Mar 19, 2018

@dperny Thanks for reviewing! Sorry about the confusion - would it help if I explained how the two different env vars used to work, in comments?

@dperny
Copy link
Copy Markdown
Collaborator

dperny commented Mar 19, 2018

Sure, yeah. It would be fine. Just something along the lines of

We set these for this reason, and we expect zyx to happen. If the code were broken, ADZ would be expected.

@cyli cyli force-pushed the remove-root-ca-key-encryption branch from e532f43 to 79964be Compare March 20, 2018 00:35
Comment thread manager/manager.go
// If we don't have a KEK, we won't need to, or can't, decrypt anything
strPassphrase := os.Getenv(ca.PassphraseENVVar)
strPassphrasePrev := os.Getenv(ca.PassphraseENVVarPrev)
if strPassphrase == "" && strPassphrasePrev == "" {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we just ignore this and try to resolve the KEK?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Er, sorry, could you explain? Do you mean ignore ca.PassphraseENVVarPrev, and just expect someone to give us the current passphrase?

Comment thread manager/manager_test.go Outdated

// Tests manager rotates encryption of root key data in the raft store
func TestManagerEncryptsDecryptsRootKeyMaterial(t *testing.T) {
// If the root CA key was encrypted in raft, on startup, the manager would decrypt the key
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

// TestManagerDecryptsRootKeyMaterial ...

@stevvooe
Copy link
Copy Markdown
Contributor

LGTM with minor nits.

@dperny I think @cyli did some nice clean up here and that is why the diff is tougher to read. For example, some if foo { /* do something */ } was replaced with if !foo { return } /* do something */ .

allow decrypting, since that feature was deprecated almost a year ago.

Signed-off-by: cyli <ying.li@docker.com>
@cyli cyli force-pushed the remove-root-ca-key-encryption branch from 79964be to de11799 Compare March 27, 2018 00:06
@cyli
Copy link
Copy Markdown
Contributor Author

cyli commented Mar 27, 2018

After IRL discussion with @stevvooe and @anshulpundir, closing this in favor of #2573 instead. Thanks for reviewing this and sorry for wasting your time @stevvooe and @dperny!

@cyli cyli closed this Mar 27, 2018
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