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

[ca] Validate the Root CA certificate before updating the security config #2234

Merged
merged 1 commit into from
Jun 9, 2017

Conversation

cyli
Copy link
Contributor

@cyli cyli commented Jun 9, 2017

Validate the Root CA certificate before updating the security config with
a new RootCA, to be sure that the root CA certificate matches the TLS
credentials already in the SecurityConfig.

This will prevent, for instance, a manager from telling an agent to load
an invalid root certificate, as can happen if an agent connects to a
manager that is being caught up via raft and hence might be replaying
old root rotations.

Signed-off-by: Ying Li ying.li@docker.com

Without this change, a manager that is catching up (for instance if it has been promoted, or if it was behind) and replying raft messages might tell all the nodes connected to it to update their root CA to an older version. This will also prevent that manager from updating to an outdated root CA as it's catching up.

This is not the most ideal change, since we're only validating when updating the root CA in the security config, but would be a quick patch to fix the issue if we want to try to get this into 17.06.

Otherwise, maybe it'd make sense to refactor SecurityConfig a bit to store the x509.Certificate and key instead of just the tls.Certificate, so that validation for everything can be moved into the SecurityConfig?

cc @aaronlehmann @diogomonica

@cyli cyli force-pushed the validate-root-ca-before-updating branch from 04f2fb3 to 095842f Compare June 9, 2017 19:46
@codecov
Copy link

codecov bot commented Jun 9, 2017

Codecov Report

Merging #2234 into master will increase coverage by 0.08%.
The diff coverage is 85.29%.

@@            Coverage Diff             @@
##           master    #2234      +/-   ##
==========================================
+ Coverage   60.16%   60.24%   +0.08%     
==========================================
  Files         124      124              
  Lines       20156    20184      +28     
==========================================
+ Hits        12127    12160      +33     
+ Misses       6661     6660       -1     
+ Partials     1368     1364       -4

ca/config.go Outdated
for i, derBytes := range tlsKeyPair.Certificate {
parsed, err := x509.ParseCertificate(derBytes)
if err != nil {
return errors.Wrap(err, "could not validate new roots because could not parse TLS cert")
Copy link
Collaborator

Choose a reason for hiding this comment

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

could not validate new root certificates due to parse error?

@aaronlehmann
Copy link
Collaborator

LGTM

…with

a new RootCA, to be sure that the root CA certificate matches the TLS
credentials already in the SecurityConfig.

This will prevent, for instance, a manager from telling an agent to load
an invalid root certificate, as can happen if an agent connects to a
manager that is being caught up via raft and hence might be replaying
old root rotations.

Signed-off-by: Ying Li <ying.li@docker.com>
@cyli cyli force-pushed the validate-root-ca-before-updating branch from 095842f to 088c952 Compare June 9, 2017 20:56
@aaronlehmann aaronlehmann merged commit cd32a7f into moby:master Jun 9, 2017
@cyli cyli deleted the validate-root-ca-before-updating branch June 10, 2017 02:05
silvin-lubecki pushed a commit to silvin-lubecki/docker-ce that referenced this pull request Feb 3, 2020
To get the changes:
* moby/swarmkit#2234
* moby/swarmkit#2237
* moby/swarmkit#2238

Signed-off-by: Andrew Hsu <andrewhsu@docker.com>
silvin-lubecki pushed a commit to silvin-lubecki/engine-extract that referenced this pull request Feb 3, 2020
To get the changes:
* moby/swarmkit#2234
* moby/swarmkit#2237
* moby/swarmkit#2238

Signed-off-by: Andrew Hsu <andrewhsu@docker.com>
silvin-lubecki pushed a commit to silvin-lubecki/engine-extract that referenced this pull request Mar 10, 2020
To get the changes:
* moby/swarmkit#2234
* moby/swarmkit#2237
* moby/swarmkit#2238

Signed-off-by: Andrew Hsu <andrewhsu@docker.com>
silvin-lubecki pushed a commit to silvin-lubecki/engine-extract that referenced this pull request Mar 23, 2020
To get the changes:
* moby/swarmkit#2234
* moby/swarmkit#2237
* moby/swarmkit#2238

Signed-off-by: Andrew Hsu <andrewhsu@docker.com>
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.

None yet

2 participants