Do not use tlsconfig.Clone, which is unsafe in go 1.7 if the config is already being used#2013
Conversation
| } | ||
|
|
||
| clientTLSConfig, err := NewClientTLSConfig(tlsKeyPair, rootCA.Pool, CARole) | ||
| clientTLSConfig, err := NewClientTLSConfig([]tls.Certificate{*tlsKeyPair}, rootCA.Pool, ManagerRole) |
There was a problem hiding this comment.
Both are fine, since the manager certificate has both as DNS names, but for consistency I changed this to the manager role instead.
| if s.ClientTLSCreds != nil { | ||
| s.ClientTLSCreds.UpdateCAs(rootCA.Pool, nil) | ||
| clientConfig := s.ClientTLSCreds.Config() | ||
| updatedClientConfig, err := NewClientTLSConfig(clientConfig.Certificates, rootCA.Pool, ManagerRole) |
There was a problem hiding this comment.
Wouldn't this reintroduce this issue: #1983 (comment) ?
There was a problem hiding this comment.
Ah right... :| in that case I will go with your suggestion of keeping a copy of the TLS config. I was hoping to do most of the cloning in the config. I actually wonder if we need to take out a lock on SecurityConfig, though, as well because RenewTLSConfigNow might update everything with an old root CA after UpdateRootCA is called.
There was a problem hiding this comment.
I added a test which attempted to simultaneously update the certs and update the root CA. It looks like I do need a lock on the root CA, because otherwise renewing the cert would overwrite the root CA changes. :|
Codecov Report
@@ Coverage Diff @@
## master #2013 +/- ##
==========================================
- Coverage 53.96% 53.79% -0.17%
==========================================
Files 109 109
Lines 18997 18980 -17
==========================================
- Hits 10251 10211 -40
- Misses 7527 7532 +5
- Partials 1219 1237 +18Continue to review full report at Codecov.
|
…ig is already being used in a server. Signed-off-by: cyli <ying.li@docker.com>
a49ce81 to
57ce2d4
Compare
Signed-off-by: cyli <ying.li@docker.com>
|
cc @diogomonica |
|
LGTM |
|
Merging to fix CI problems. @diogomonica: feel free to review post-merge. |
Rather than clone the config, since we already have utilities to create a new TLS configuration for the client and server using the TLS certs themselves and the root pool, just recreate a new TLS configuration rather than attempt to clone the existing one.
Accessing the certificates in the
tls.Configobject does not cause a data race:is fine under go 1.7 and go 1.8
Fixes #2012.