-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
credentials: Apply defaults to TLS configs provided through GetConfigForClient #7754
credentials: Apply defaults to TLS configs provided through GetConfigForClient #7754
Conversation
b3de47d
to
87016c7
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #7754 +/- ##
==========================================
+ Coverage 79.70% 79.81% +0.11%
==========================================
Files 365 365
Lines 36383 36394 +11
==========================================
+ Hits 29000 29049 +49
+ Misses 6183 6154 -29
+ Partials 1200 1191 -9
|
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.
Thanks for the PR!
I think this is good, NewTLS
should (generally) support the features of the tls.Config
where we can and it makes sense. WDYT Matt?
I haven't done a pass on the test file yet, I'll go through that when we are sure we want to add this handling in general.
credentials/tls.go
Outdated
@@ -200,25 +200,41 @@ var tls12ForbiddenCipherSuites = map[uint16]struct{}{ | |||
|
|||
// NewTLS uses c to construct a TransportCredentials based on TLS. | |||
func NewTLS(c *tls.Config) TransportCredentials { | |||
tc := &tlsCreds{credinternal.CloneTLSConfig(c)} | |||
tc.config.NextProtos = credinternal.AppendH2ToNextProtos(tc.config.NextProtos) | |||
cfg := applyDefaults(c) |
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.
Don't shorten names - cfg
-> config
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.
Changed as suggested.
credentials/tls.go
Outdated
return applyDefaults(cfgForClient), nil | ||
} | ||
} | ||
tc := &tlsCreds{config: cfg} |
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.
nit tc -> creds
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.
removed the temporary variable an inlined the return.
Also, regarding the release notes, let's specify that this is specifically for credentials: TLS credentials created via |
Updated, thanks for the suggestion. |
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.
LGTM.
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.
Just that one test structure question, otherwise LGTM
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.
Thanks for the fix!
Fixes: #7709
TLS server configs provided at TLS handshake time through
GetConfigForClient
were not modified by grpc-go to ensure secure defaults and a valid ALPN configuration. This PR applies the same handling applied to static TLS configs to the configs obtained byGetConfigForClient
.RELEASE NOTES:
NewTLS
that usetls.Config.GetConfigForClient
will now have necessary gRPC-Go defaults, namely CipherSuites, supported TLS versions and ALPN configured automatically. This handling was already present for configs not using the GetConfigForClient function.