Skip to content

Commit 9022a54

Browse files
committed
tlsconfig: align client and server defaults, remove weak CBC ciphers
These ciphers were split between server and client in [docker/go-connections@9b43f5a] (Docker v1.8.0, Jun 11, 2015); > removing the CBC ciphers from the client preferred TLS cipher suites. > This will allow a future version of the server to also remove the CBC > ciphers from the accepted list. > > This changes the server default to client + additional CBC cipher list, > and client default to the non-CBC ciphers. That change allowed phasing out the use of these ciphers in the client, but (for backward-compatibility with older clients) the daemon to still accept old ones. Given that no current client versions should still be using these, we should be able to remove them from the list of ciphers that are supported by the daemon. Now that client and server are the same, we can also use a single implementation for both. [docker/go-connections@9b43f5a]: moby/moby@9b43f5a Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 777df48 commit 9022a54

3 files changed

Lines changed: 19 additions & 40 deletions

File tree

tlsconfig/config.go

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,40 +36,33 @@ type Options struct {
3636
MinVersion uint16
3737
}
3838

39-
// Extra (server-side) accepted CBC cipher suites - will phase out in the future
40-
var acceptedCBCCiphers = []uint16{
41-
tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
42-
tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
43-
tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
44-
tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
45-
}
46-
4739
// DefaultServerAcceptedCiphers should be uses by code which already has a crypto/tls
4840
// options struct but wants to use a commonly accepted set of TLS cipher suites, with
4941
// known weak algorithms removed.
50-
var DefaultServerAcceptedCiphers = append(clientCipherSuites, acceptedCBCCiphers...)
42+
var DefaultServerAcceptedCiphers = defaultCipherSuites
43+
44+
var defaultCipherSuites = []uint16{
45+
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
46+
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
47+
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
48+
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
49+
}
5150

5251
// ServerDefault returns a secure-enough TLS configuration for the server TLS configuration.
5352
func ServerDefault(ops ...func(*tls.Config)) *tls.Config {
54-
tlsConfig := &tls.Config{
55-
// Avoid fallback by default to SSL protocols < TLS1.2
56-
MinVersion: tls.VersionTLS12,
57-
CipherSuites: DefaultServerAcceptedCiphers,
58-
}
59-
60-
for _, op := range ops {
61-
op(tlsConfig)
62-
}
63-
64-
return tlsConfig
53+
return defaultConfig(ops...)
6554
}
6655

6756
// ClientDefault returns a secure-enough TLS configuration for the client TLS configuration.
6857
func ClientDefault(ops ...func(*tls.Config)) *tls.Config {
58+
return defaultConfig(ops...)
59+
}
60+
61+
func defaultConfig(ops ...func(*tls.Config)) *tls.Config {
6962
tlsConfig := &tls.Config{
70-
// Prefer TLS1.2 as the client minimum
63+
// Avoid fallback by default to SSL protocols < TLS1.2
7164
MinVersion: tls.VersionTLS12,
72-
CipherSuites: clientCipherSuites,
65+
CipherSuites: defaultCipherSuites,
7366
}
7467

7568
for _, op := range ops {
@@ -199,7 +192,7 @@ func getCert(options Options) ([]tls.Certificate, error) {
199192

200193
// Client returns a TLS configuration meant to be used by a client.
201194
func Client(options Options) (*tls.Config, error) {
202-
tlsConfig := ClientDefault()
195+
tlsConfig := defaultConfig()
203196
tlsConfig.InsecureSkipVerify = options.InsecureSkipVerify
204197
if !options.InsecureSkipVerify && options.CAFile != "" {
205198
CAs, err := certPool(options.CAFile, options.ExclusiveRootPools)
@@ -224,7 +217,7 @@ func Client(options Options) (*tls.Config, error) {
224217

225218
// Server returns a TLS configuration meant to be used by a server.
226219
func Server(options Options) (*tls.Config, error) {
227-
tlsConfig := ServerDefault()
220+
tlsConfig := defaultConfig()
228221
tlsConfig.ClientAuth = options.ClientAuth
229222
tlsCert, err := tls.LoadX509KeyPair(options.CertFile, options.KeyFile)
230223
if err != nil {

tlsconfig/config_client_ciphers.go

Lines changed: 0 additions & 14 deletions
This file was deleted.

tlsconfig/config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ func TestConfigClientTLSNoVerify(t *testing.T) {
395395
t.Fatal("Should not have set Root CAs", err)
396396
}
397397

398-
if !reflect.DeepEqual(tlsConfig.CipherSuites, clientCipherSuites) {
398+
if !reflect.DeepEqual(tlsConfig.CipherSuites, defaultCipherSuites) {
399399
t.Fatal("Unexpected client cipher suites")
400400
}
401401
if tlsConfig.MinVersion != tls.VersionTLS12 {
@@ -420,7 +420,7 @@ func TestConfigClientTLSNoRoot(t *testing.T) {
420420
t.Fatal("Should not have set Root CAs", err)
421421
}
422422

423-
if !reflect.DeepEqual(tlsConfig.CipherSuites, clientCipherSuites) {
423+
if !reflect.DeepEqual(tlsConfig.CipherSuites, defaultCipherSuites) {
424424
t.Fatal("Unexpected client cipher suites")
425425
}
426426
if tlsConfig.MinVersion != tls.VersionTLS12 {

0 commit comments

Comments
 (0)