-
Notifications
You must be signed in to change notification settings - Fork 12
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
Default to TLS 1.2 as minimum version #62
Conversation
baseapp/params.go
Outdated
@@ -47,6 +48,7 @@ func DefaultParams(logger zerolog.Logger, metricsPrefix string) []Param { | |||
WithUTCNanoTime(), | |||
WithErrorLogging(RichErrorMarshalFunc), | |||
WithMetrics(), | |||
WithTLSConfig(&tls.Config{MinVersion: tls.VersionTLS12}), |
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 to add MinVersion to the TLSConfig struct? Perhaps adding these options set to their defaults in the example/config.yaml
may help with discoverability as well?
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.
hrmm. i guess it depends on how we want to treat server.TLSConfig
(as opposed to our YAML object) configuration: is it runtime configurable, specifically: will a single binary be deployed to different scenarios where we want to set the minimum TLS version.
considering TLS 1.0 and 1.1 have been widely deprecated since early 2020, i feel okay with the cost of downstream consumers that require TLS 1.0/1.1 support to explicitly add code to set the server.TLSConfig.MinVersion
in their services.
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.
I think we should leave this as a code-only option until there are two or more places where having it as part of the configuration file would be useful.
👍 |
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.
Setting the minimum TLS version to 1.2 when TLS is enabled sounds reasonable to me. A few things to consider:
- Is the
tls.Config
struct ignored when callingListenAndServe
instead ofListenAndServeTLS
? WithTLSConfig()
sounds reasonable but introduces a third way to modify these settings. Clients can currently useWithHTTPServer
to provide a pre-configured server or useHTTPServer()
to access and modify the underlying server instance before callingStart()
. While modifying the server after creation always wins, it might not be clear howWithHTTPServer
andWithTLSConfig
interact if both are provided.
baseapp/params.go
Outdated
@@ -47,6 +48,7 @@ func DefaultParams(logger zerolog.Logger, metricsPrefix string) []Param { | |||
WithUTCNanoTime(), | |||
WithErrorLogging(RichErrorMarshalFunc), | |||
WithMetrics(), | |||
WithTLSConfig(&tls.Config{MinVersion: tls.VersionTLS12}), |
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.
I think we should leave this as a code-only option until there are two or more places where having it as part of the configuration file would be useful.
baseapp/params.go
Outdated
|
||
func WithTLSConfig(tlsConfig *tls.Config) Param { | ||
return func(s *Server) error { | ||
s.server.TLSConfig = tlsConfig |
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.
s.server
is nil
when Param
functions are called, unless WithHTTPServer
appears earlier in the parameter list.
this makes sense to me. I've changed the impl to just create the |
The stdlib's HTTP server allows TLS 1.0 / 1.1 connections by default. This library should be secure by default and require TLS 1.2 as the minimum TSL version.
This PR does the following:
Param
calledWithTLSConfig
which allows the user to set the TLS configurationWithTLSConfig
to theDefaultParams
that sets the MinVersion to TLS 1.2Downstream owners can opt out of using TLS 1.2 by adding their own Param or configuring their
http/server
themselves.