-
Notifications
You must be signed in to change notification settings - Fork 347
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
feat: Implement setting common TLS parameters in ClientTrafficPolicy #2297
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d123519
api: Add TLS configuration attributes in ClientTrafficPolicy
liorokman 1ff29a6
Fixed typos in the comments.
liorokman 006b2de
Updated the comment for `TLSSettings`.
liorokman eb107f3
Regenerated after rebasing
liorokman 38c71a0
api: Add TLS configuration attributes in ClientTrafficPolicy
liorokman 586930f
feat: Implement setting common TLS parameters in ClientTrafficPolicy.
liorokman 3e2cb94
Fixed linter and gen-check errors
liorokman 25ce728
Implement the changes required after the reviewed API
liorokman 690a180
Set ALPN protocols in QUIC in the same way as in HTTPS
liorokman 04b8c57
* Regenerated and recreated the manifests after rebase
liorokman 29de70f
Alphabetize the output test yamls to make "gen-check" pass
liorokman ee61396
* Remove references to the API from the XDS layer
liorokman d305be0
Changed the TLS protocol version constants to have a dot instead of an
liorokman 829457a
* Reworked the ALPN logic so that an empty array in the IR layer
liorokman 6b6722b
Make gen-check pass
liorokman 3ca7a9a
* Require that ALPN constants are also valid ALPN identification
liorokman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -309,6 +309,9 @@ func (t *Translator) translateClientTrafficPolicyForListener(policySpec *egv1a1. | |
proxyListenerIR.HTTP3 = &ir.HTTP3Settings{} | ||
} | ||
} | ||
|
||
// Translate TLS parameters | ||
translateListenerTLSParameters(policySpec.TLS, httpIR) | ||
} | ||
} | ||
|
||
|
@@ -359,3 +362,45 @@ func translateListenerSuppressEnvoyHeaders(suppressEnvoyHeaders *bool, httpIR *i | |
httpIR.SuppressEnvoyHeaders = *suppressEnvoyHeaders | ||
} | ||
} | ||
|
||
func translateListenerTLSParameters(tlsParams *egv1a1.TLSSettings, httpIR *ir.HTTPListener) { | ||
// Return if this listener isn't a TLS listener. There has to be | ||
// at least one certificate defined, which would cause httpIR to | ||
// have a TLS structure. | ||
if httpIR.TLS == nil { | ||
return | ||
} | ||
// Make sure that the negotiated TLS protocol version is as expected if TLS is used, | ||
// regardless of if TLS parameters were used in the ClientTrafficPolicy or not | ||
httpIR.TLS.MinVersion = ptr.To(ir.TLSv12) | ||
httpIR.TLS.MaxVersion = ptr.To(ir.TLSv13) | ||
// If HTTP3 is enabled, the ALPN protocols array should be hardcoded | ||
arkodg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// for HTTP3 | ||
if httpIR.HTTP3 != nil { | ||
httpIR.TLS.ALPNProtocols = []string{"h3"} | ||
} else if tlsParams != nil && len(tlsParams.ALPNProtocols) > 0 { | ||
httpIR.TLS.ALPNProtocols = make([]string, len(tlsParams.ALPNProtocols)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldnt this line
be under else it will end up resetting the value There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
for i := range tlsParams.ALPNProtocols { | ||
httpIR.TLS.ALPNProtocols[i] = string(tlsParams.ALPNProtocols[i]) | ||
} | ||
} | ||
// Return early if not set | ||
if tlsParams == nil { | ||
return | ||
} | ||
if tlsParams.MinVersion != nil { | ||
httpIR.TLS.MinVersion = ptr.To(ir.TLSVersion(*tlsParams.MinVersion)) | ||
} | ||
if tlsParams.MaxVersion != nil { | ||
httpIR.TLS.MaxVersion = ptr.To(ir.TLSVersion(*tlsParams.MaxVersion)) | ||
} | ||
if len(tlsParams.Ciphers) > 0 { | ||
httpIR.TLS.Ciphers = tlsParams.Ciphers | ||
} | ||
if len(tlsParams.ECDHCurves) > 0 { | ||
httpIR.TLS.ECDHCurves = tlsParams.ECDHCurves | ||
} | ||
if len(tlsParams.SignatureAlgorithms) > 0 { | ||
httpIR.TLS.SignatureAlgorithms = tlsParams.SignatureAlgorithms | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file modified
0
internal/gatewayapi/testdata/backendtrafficpolicy-with-circuitbreakers-error.out.yaml
100755 → 100644
Empty file.
Empty file modified
0
internal/gatewayapi/testdata/backendtrafficpolicy-with-circuitbreakers.out.yaml
100755 → 100644
Empty file.
Empty file modified
0
internal/gatewayapi/testdata/backendtrafficpolicy-with-loadbalancer.out.yaml
100755 → 100644
Empty file.
Empty file modified
0
...api/testdata/backendtrafficpolicy-with-local-ratelimit-default-route-level-limit.out.yaml
100755 → 100644
Empty file.
Empty file modified
0
...gatewayapi/testdata/backendtrafficpolicy-with-local-ratelimit-invalid-limit-unit.out.yaml
100755 → 100644
Empty file.
Empty file modified
0
...gatewayapi/testdata/backendtrafficpolicy-with-local-ratelimit-invalid-match-type.out.yaml
100755 → 100644
Empty file.
Empty file modified
0
...ta/backendtrafficpolicy-with-local-ratelimit-invalid-multiple-route-level-limits.out.yaml
100755 → 100644
Empty file.
Empty file modified
0
internal/gatewayapi/testdata/backendtrafficpolicy-with-local-ratelimit.out.yaml
100755 → 100644
Empty file.
Empty file modified
0
internal/gatewayapi/testdata/backendtrafficpolicy-with-proxyprotocol.out.yaml
100755 → 100644
Empty file.
Empty file modified
0
internal/gatewayapi/testdata/backendtrafficpolicy-with-ratelimit-invalid-regex.out.yaml
100755 → 100644
Empty file.
Empty file modified
0
internal/gatewayapi/testdata/backendtrafficpolicy-with-ratelimit.out.yaml
100755 → 100644
Empty file.
Empty file modified
0
internal/gatewayapi/testdata/backendtrafficpolicy-with-same-prefix-httproutes.out.yaml
100755 → 100644
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file modified
0
internal/gatewayapi/testdata/clienttrafficpolicy-proxyprotocol.out.yaml
100755 → 100644
Empty file.
Empty file modified
0
internal/gatewayapi/testdata/clienttrafficpolicy-suppress-envoy-headers.out.yaml
100755 → 100644
Empty file.
Empty file modified
0
internal/gatewayapi/testdata/clienttrafficpolicy-tcp-keepalive.out.yaml
100755 → 100644
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
can you add some test for these in a separated PR.
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.
Added #2424