-
Notifications
You must be signed in to change notification settings - Fork 656
ca: when the Root CA is updated in the security config, update all TLS creds too #1983
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ import ( | |
| "strings" | ||
| "sync" | ||
|
|
||
| "github.com/docker/docker/pkg/tlsconfig" | ||
| "github.com/pkg/errors" | ||
| "golang.org/x/net/context" | ||
| "google.golang.org/grpc/credentials" | ||
|
|
@@ -135,6 +136,16 @@ func (c *MutableTLSCreds) LoadNewTLSConfig(newConfig *tls.Config) error { | |
| return nil | ||
| } | ||
|
|
||
| // UpdateCAs updates the root CAs and client CAs of the existing TLS config in place | ||
| func (c *MutableTLSCreds) UpdateCAs(rootCAs, clientCAs *x509.CertPool) { | ||
| c.Lock() | ||
| defer c.Unlock() | ||
| config := tlsconfig.Clone(c.config) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need to clone instead of directly modifying it?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried that originally, but it's not really safe to modify a
|
||
| config.RootCAs = rootCAs | ||
| config.ClientCAs = clientCAs | ||
| c.config = config | ||
| } | ||
|
|
||
| // Config returns the current underlying TLS config. | ||
| func (c *MutableTLSCreds) Config() *tls.Config { | ||
| c.Lock() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need locking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh: #1983 (comment)