-
Notifications
You must be signed in to change notification settings - Fork 10
feat: implement TLS groups/curve preferences support #22
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,22 +123,26 @@ func GetTLSProfileSpec(profile *configv1.TLSSecurityProfile) (configv1.TLSProfil | |
| // Note: CipherSuites are only set when MinVersion is below TLS 1.3, as Go's TLS 1.3 implementation | ||
| // does not allow configuring cipher suites - all TLS 1.3 ciphers are always enabled. | ||
| // See: https://github.com/golang/go/issues/29349 | ||
| func NewTLSConfigFromProfile(profile configv1.TLSProfileSpec) (tlsConfig func(*tls.Config), unsupportedCiphers []string) { | ||
| func NewTLSConfigFromProfile(profile configv1.TLSProfileSpec) (tlsConfig func(*tls.Config), unsupported []string) { | ||
| minVersion := libgocrypto.TLSVersionOrDie(string(profile.MinTLSVersion)) | ||
| cipherSuites, unsupportedCiphers := cipherCodes(profile.Ciphers) | ||
| curvePrefs, unsupportedGroups := libgocrypto.CurveIDsForTLSGroups(profile.Groups) | ||
|
|
||
| unsupported = append(unsupportedCiphers, unsupportedGroups...) | ||
|
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. Is there any value in separating the two types here?
Member
Author
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. I think merging is fine here. The caller only uses unsupported for logging ("unsupported ciphers/groups that will be ignored: %v"). Separating them would change the function signature (e.g., return two slices, or a struct) for no practical benefit, the caller doesn't need to handle them differently. If a consumer ever needs to distinguish, libgocrypto.CurveIDsForTLSGroups and cipherCodes are individually callable. |
||
|
|
||
| return func(tlsConf *tls.Config) { | ||
| tlsConf.MinVersion = minVersion | ||
| // TODO: add curve preferences from profile once https://github.com/openshift/api/pull/2583 merges. | ||
| // tlsConf.CurvePreferences <<<<<< profile.Curves | ||
| if len(curvePrefs) > 0 { | ||
| tlsConf.CurvePreferences = curvePrefs | ||
| } | ||
|
|
||
| // TLS 1.3 cipher suites are not configurable in Go (https://github.com/golang/go/issues/29349), so only set CipherSuites accordingly. | ||
| // TODO: revisit this once we get an answer on the best way to handle this here: | ||
| // https://docs.google.com/document/d/1cMc9E8psHfnoK06ntR8kHSWB8d3rMtmldhnmM4nImjs/edit?disco=AAABu_nPcYg | ||
| if minVersion != tls.VersionTLS13 { | ||
| tlsConf.CipherSuites = cipherSuites | ||
| } | ||
| }, unsupportedCiphers | ||
| }, unsupported | ||
|
Comment on lines
+126
to
+145
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. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Locate the vendored library-go crypto package and inspect CurveIDsForTLSGroups signature
fd -a 'crypto.go' --path '*library-go/pkg/crypto*'
rg -n -A 15 'func CurveIDsForTLSGroups' -g '*.go'Repository: openshift/controller-runtime-common Length of output: 405 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '== go.mod references =='
rg -n 'library-go|CurveIDsForTLSGroups|TLSGroup|TLSProfileSpec' go.mod go.sum vendor . || true
echo
echo '== locate tls.go =='
fd -a 'tls.go' pkg || true
echo
echo '== outline pkg/tls/tls.go =='
if command -v ast-grep >/dev/null 2>&1; then
ast-grep outline pkg/tls/tls.go --view expanded || true
fi
echo
echo '== relevant lines in pkg/tls/tls.go =='
nl -ba pkg/tls/tls.go | sed -n '1,220p'Repository: openshift/controller-runtime-common Length of output: 26899 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '== dependency metadata =='
rg -n 'openshift/library-go|library-go' go.mod go.sum vendor . || true
echo
echo '== search for CurveIDsForTLSGroups in repo =='
rg -n 'CurveIDsForTLSGroups|TLSGroup' . || true
echo
echo '== inspect pkg/tls tests =='
fd -a 'tls_test.go' pkg || true
if [ -f pkg/tls/tls_test.go ]; then
nl -ba pkg/tls/tls_test.go | sed -n '1,260p'
fiRepository: openshift/controller-runtime-common Length of output: 9811 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '== vendor CurveIDsForTLSGroups implementation =='
sed -n '392,420p' vendor/github.com/openshift/library-go/pkg/crypto/crypto.go
echo
echo '== tls tests around unsupported groups =='
sed -n '286,360p' pkg/tls/tls_test.goRepository: openshift/controller-runtime-common Length of output: 3714 Normalize unsupported group names 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| // SetNextProtos returns a TLS configuration function that sets the ALPN | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.