Skip to content

Commit 07aef67

Browse files
Refactoring tls.Config mutation out of grpc (letsencrypt#5175)
In all boulder services, we construct a single tls.Config object and then pass it into multiple gRPC setup methods. In all boulder services but one, we pass the object into multiple clients, and just one server. In general, this is safe, because all of the client setup happens on the main thread, and the server setup similarly happens on the main thread before spinning off the gRPC server goroutine. In the CA, we do the above and pass the tlsConfig object into two gRPC server setup functions. Thus the first server goroutine races with the setup of the second server. This change removes the post-hoc assignment of MinVersion, MaxVersion, and CipherSuites of the tls.Config object passed to grpc.ClientSetup and grpc.NewServer. And adds those same values to the cmd.TLSConfig.Load, the method responsible for constructing the tls.Config object before it's passed to grpc.ClientSetup and grpc.NewServer. Part of letsencrypt#5159
1 parent bcca7c2 commit 07aef67

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

cmd/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ func (t *TLSConfig) Load() (*tls.Config, error) {
138138
ClientCAs: rootCAs,
139139
ClientAuth: tls.RequireAndVerifyClientCert,
140140
Certificates: []tls.Certificate{cert},
141+
// Set the only acceptable TLS version to 1.2 and the only acceptable cipher suite
142+
// to ECDHE-RSA-CHACHA20-POLY1305.
143+
MinVersion: tls.VersionTLS12,
144+
MaxVersion: tls.VersionTLS12,
145+
CipherSuites: []uint16{tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305},
141146
}, nil
142147
}
143148

grpc/client.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ func ClientSetup(c *cmd.GRPCClientConfig, tlsConfig *tls.Config, metrics clientM
3232
return nil, errNilTLS
3333
}
3434

35-
// Set the only acceptable TLS version to 1.2 and the only acceptable cipher suite
36-
// to ECDHE-RSA-CHACHA20-POLY1305.
37-
tlsConfig.MinVersion, tlsConfig.MaxVersion = tls.VersionTLS12, tls.VersionTLS12
38-
tlsConfig.CipherSuites = []uint16{tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305}
39-
4035
ci := clientInterceptor{c.Timeout.Duration, metrics, clk}
4136
host, _, err := net.SplitHostPort(c.ServerAddress)
4237
if err != nil {

grpc/server.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ func NewServer(c *cmd.GRPCServerConfig, tlsConfig *tls.Config, metrics serverMet
3131
acceptedSANs[name] = struct{}{}
3232
}
3333

34-
// Set the only acceptable TLS version to 1.2 and the only acceptable cipher suite
35-
// to ECDHE-RSA-CHACHA20-POLY1305.
36-
tlsConfig.MinVersion, tlsConfig.MaxVersion = tls.VersionTLS12, tls.VersionTLS12
37-
tlsConfig.CipherSuites = []uint16{tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305}
38-
3934
creds, err := bcreds.NewServerCredentials(tlsConfig, acceptedSANs)
4035
if err != nil {
4136
return nil, nil, err

0 commit comments

Comments
 (0)