Skip to content

Commit 6203811

Browse files
authored
allow user to specify tls version for backward compatibility (#7654)
* optional tls version logic Signed-off-by: pureiboi <[email protected]> * update cmd description and match doc Signed-off-by: pureiboi <[email protected]> * feat: update doc with make docs Signed-off-by: pureiboi <[email protected]> * fix indentation by linter Signed-off-by: pureiboi <[email protected]> --------- Signed-off-by: pureiboi <[email protected]> Signed-off-by: pureiboi <[email protected]
1 parent 19dc4b9 commit 6203811

File tree

15 files changed

+158
-21
lines changed

15 files changed

+158
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
3434
- [#7659](https://github.com/thanos-io/thanos/pull/7659) Receive: Add support for replication using [Cap'n Proto](https://capnproto.org/). This protocol has a lower CPU and memory footprint, which leads to a reduction in resource usage in Receivers. Before enabling it, make sure that all receivers are updated to a version which supports this replication method.
3535
- [#7853](https://github.com/thanos-io/thanos/pull/7853) UI: Add support for selecting graph time range with mouse drag.
3636
- [#7855](https://github.com/thanos-io/thanos/pull/7855) Compcat/Query: Add support for comma separated replica labels.
37+
- [#7654](https://github.com/thanos-io/thanos/pull/7654) *: Add '--grpc-server-tls-min-version' flag to allow user to specify TLS version, otherwise default to TLS 1.3
3738

3839
### Changed
3940

cmd/thanos/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type grpcConfig struct {
2828
tlsSrvCert string
2929
tlsSrvKey string
3030
tlsSrvClientCA string
31+
tlsMinVersion string
3132
gracePeriod time.Duration
3233
maxConnectionAge time.Duration
3334
}
@@ -45,6 +46,9 @@ func (gc *grpcConfig) registerFlag(cmd extkingpin.FlagClause) *grpcConfig {
4546
cmd.Flag("grpc-server-tls-client-ca",
4647
"TLS CA to verify clients against. If no client CA is specified, there is no client verification on server side. (tls.NoClientCert)").
4748
Default("").StringVar(&gc.tlsSrvClientCA)
49+
cmd.Flag("grpc-server-tls-min-version",
50+
"TLS supported minimum version for gRPC server. If no version is specified, it'll default to 1.3. Allowed values: [\"1.0\", \"1.1\", \"1.2\", \"1.3\"]").
51+
Default("1.3").StringVar(&gc.tlsMinVersion)
4852
cmd.Flag("grpc-server-max-connection-age", "The grpc server max connection age. This controls how often to re-establish connections and redo TLS handshakes.").
4953
Default("60m").DurationVar(&gc.maxConnectionAge)
5054
cmd.Flag("grpc-grace-period",

cmd/thanos/query.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ func runQuery(
793793
}
794794
// Start query (proxy) gRPC StoreAPI.
795795
{
796-
tlsCfg, err := tls.NewServerConfig(log.With(logger, "protocol", "gRPC"), grpcServerConfig.tlsSrvCert, grpcServerConfig.tlsSrvKey, grpcServerConfig.tlsSrvClientCA)
796+
tlsCfg, err := tls.NewServerConfig(log.With(logger, "protocol", "gRPC"), grpcServerConfig.tlsSrvCert, grpcServerConfig.tlsSrvKey, grpcServerConfig.tlsSrvClientCA, grpcServerConfig.tlsMinVersion)
797797
if err != nil {
798798
return errors.Wrap(err, "setup gRPC server")
799799
}

cmd/thanos/receive.go

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func runReceive(
149149
}
150150
}
151151

152-
rwTLSConfig, err := tls.NewServerConfig(log.With(logger, "protocol", "HTTP"), conf.rwServerCert, conf.rwServerKey, conf.rwServerClientCA)
152+
rwTLSConfig, err := tls.NewServerConfig(log.With(logger, "protocol", "HTTP"), conf.rwServerCert, conf.rwServerKey, conf.rwServerClientCA, conf.rwServerTlsMinVersion)
153153
if err != nil {
154154
return err
155155
}
@@ -331,7 +331,7 @@ func runReceive(
331331

332332
level.Debug(logger).Log("msg", "setting up gRPC server")
333333
{
334-
tlsCfg, err := tls.NewServerConfig(log.With(logger, "protocol", "gRPC"), conf.grpcConfig.tlsSrvCert, conf.grpcConfig.tlsSrvKey, conf.grpcConfig.tlsSrvClientCA)
334+
tlsCfg, err := tls.NewServerConfig(log.With(logger, "protocol", "gRPC"), conf.grpcConfig.tlsSrvCert, conf.grpcConfig.tlsSrvKey, conf.grpcConfig.tlsSrvClientCA, conf.grpcConfig.tlsMinVersion)
335335
if err != nil {
336336
return errors.Wrap(err, "setup gRPC server")
337337
}
@@ -818,17 +818,18 @@ type receiveConfig struct {
818818

819819
grpcConfig grpcConfig
820820

821-
replicationAddr string
822-
rwAddress string
823-
rwServerCert string
824-
rwServerKey string
825-
rwServerClientCA string
826-
rwClientCert string
827-
rwClientKey string
828-
rwClientSecure bool
829-
rwClientServerCA string
830-
rwClientServerName string
831-
rwClientSkipVerify bool
821+
replicationAddr string
822+
rwAddress string
823+
rwServerCert string
824+
rwServerKey string
825+
rwServerClientCA string
826+
rwClientCert string
827+
rwClientKey string
828+
rwClientSecure bool
829+
rwClientServerCA string
830+
rwClientServerName string
831+
rwClientSkipVerify bool
832+
rwServerTlsMinVersion string
832833

833834
dataDir string
834835
labelStrs []string
@@ -901,6 +902,8 @@ func (rc *receiveConfig) registerFlag(cmd extkingpin.FlagClause) {
901902

902903
cmd.Flag("remote-write.server-tls-client-ca", "TLS CA to verify clients against. If no client CA is specified, there is no client verification on server side. (tls.NoClientCert)").Default("").StringVar(&rc.rwServerClientCA)
903904

905+
cmd.Flag("remote-write.server-tls-min-version", "TLS version for the gRPC server, leave blank to default to TLS 1.3, allow values: [\"1.0\", \"1.1\", \"1.2\", \"1.3\"]").Default("1.3").StringVar(&rc.rwServerTlsMinVersion)
906+
904907
cmd.Flag("remote-write.client-tls-cert", "TLS Certificates to use to identify this client to the server.").Default("").StringVar(&rc.rwClientCert)
905908

906909
cmd.Flag("remote-write.client-tls-key", "TLS Key for the client's certificate.").Default("").StringVar(&rc.rwClientKey)

cmd/thanos/rule.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ func runRule(
730730
)
731731

732732
// Start gRPC server.
733-
tlsCfg, err := tls.NewServerConfig(log.With(logger, "protocol", "gRPC"), conf.grpc.tlsSrvCert, conf.grpc.tlsSrvKey, conf.grpc.tlsSrvClientCA)
733+
tlsCfg, err := tls.NewServerConfig(log.With(logger, "protocol", "gRPC"), conf.grpc.tlsSrvCert, conf.grpc.tlsSrvKey, conf.grpc.tlsSrvClientCA, conf.grpc.tlsMinVersion)
734734
if err != nil {
735735
return errors.Wrap(err, "setup gRPC server")
736736
}

cmd/thanos/sidecar.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ func runSidecar(
303303
}
304304

305305
tlsCfg, err := tls.NewServerConfig(log.With(logger, "protocol", "gRPC"),
306-
conf.grpc.tlsSrvCert, conf.grpc.tlsSrvKey, conf.grpc.tlsSrvClientCA)
306+
conf.grpc.tlsSrvCert, conf.grpc.tlsSrvKey, conf.grpc.tlsSrvClientCA, conf.grpc.tlsMinVersion)
307307
if err != nil {
308308
return errors.Wrap(err, "setup gRPC server")
309309
}

cmd/thanos/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ func runStore(
516516

517517
// Start query (proxy) gRPC StoreAPI.
518518
{
519-
tlsCfg, err := tls.NewServerConfig(log.With(logger, "protocol", "gRPC"), conf.grpcConfig.tlsSrvCert, conf.grpcConfig.tlsSrvKey, conf.grpcConfig.tlsSrvClientCA)
519+
tlsCfg, err := tls.NewServerConfig(log.With(logger, "protocol", "gRPC"), conf.grpcConfig.tlsSrvCert, conf.grpcConfig.tlsSrvKey, conf.grpcConfig.tlsSrvClientCA, conf.grpcConfig.tlsMinVersion)
520520
if err != nil {
521521
return errors.Wrap(err, "setup gRPC server")
522522
}

docs/components/query.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,11 @@ Flags:
353353
verification on server side. (tls.NoClientCert)
354354
--grpc-server-tls-key="" TLS Key for the gRPC server, leave blank to
355355
disable TLS
356+
--grpc-server-tls-min-version="1.3"
357+
TLS supported minimum version for gRPC server.
358+
If no version is specified, it'll default to
359+
1.3. Allowed values: ["1.0", "1.1", "1.2",
360+
"1.3"]
356361
-h, --help Show context-sensitive help (also try
357362
--help-long and --help-man).
358363
--http-address="0.0.0.0:10902"

docs/components/receive.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,11 @@ Flags:
380380
verification on server side. (tls.NoClientCert)
381381
--grpc-server-tls-key="" TLS Key for the gRPC server, leave blank to
382382
disable TLS
383+
--grpc-server-tls-min-version="1.3"
384+
TLS supported minimum version for gRPC server.
385+
If no version is specified, it'll default to
386+
1.3. Allowed values: ["1.0", "1.1", "1.2",
387+
"1.3"]
383388
--hash-func= Specify which hash function to use when
384389
calculating the hashes of produced files.
385390
If no function has been specified, it does not
@@ -508,6 +513,10 @@ Flags:
508513
--remote-write.server-tls-key=""
509514
TLS Key for the HTTP server, leave blank to
510515
disable TLS.
516+
--remote-write.server-tls-min-version="1.3"
517+
TLS version for the gRPC server, leave blank
518+
to default to TLS 1.3, allow values: ["1.0",
519+
"1.1", "1.2", "1.3"]
511520
--request.logging-config=<content>
512521
Alternative to 'request.logging-config-file'
513522
flag (mutually exclusive). Content

docs/components/rule.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,11 @@ Flags:
352352
verification on server side. (tls.NoClientCert)
353353
--grpc-server-tls-key="" TLS Key for the gRPC server, leave blank to
354354
disable TLS
355+
--grpc-server-tls-min-version="1.3"
356+
TLS supported minimum version for gRPC server.
357+
If no version is specified, it'll default to
358+
1.3. Allowed values: ["1.0", "1.1", "1.2",
359+
"1.3"]
355360
--hash-func= Specify which hash function to use when
356361
calculating the hashes of produced files.
357362
If no function has been specified, it does not

0 commit comments

Comments
 (0)