Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .bingo/Variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ $(CRD_REF_DOCS): $(BINGO_DIR)/crd-ref-docs.mod
@echo "(re)installing $(GOBIN)/crd-ref-docs-v0.1.0"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=crd-ref-docs.mod -o=$(GOBIN)/crd-ref-docs-v0.1.0 "github.com/elastic/crd-ref-docs"

GOJQ := $(GOBIN)/gojq-v0.12.17
$(GOJQ): $(BINGO_DIR)/gojq.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/gojq-v0.12.17"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=gojq.mod -o=$(GOBIN)/gojq-v0.12.17 "github.com/itchyny/gojq/cmd/gojq"

GOLANGCI_LINT := $(GOBIN)/golangci-lint-v2.1.6
$(GOLANGCI_LINT): $(BINGO_DIR)/golangci-lint.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
Expand Down
5 changes: 5 additions & 0 deletions .bingo/gojq.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.24.4

require github.com/itchyny/gojq v0.12.17 // cmd/gojq
17 changes: 17 additions & 0 deletions .bingo/gojq.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
github.com/itchyny/gojq v0.12.17 h1:8av8eGduDb5+rvEdaOO+zQUjA04MS0m3Ps8HiD+fceg=
github.com/itchyny/gojq v0.12.17/go.mod h1:WBrEMkgAfAGO1LUcGOckBl5O726KPp+OlkKug0I/FEY=
github.com/itchyny/timefmt-go v0.1.6 h1:ia3s54iciXDdzWzwaVKXZPbiXzxxnv1SPGFfM/myJ5Q=
github.com/itchyny/timefmt-go v0.1.6/go.mod h1:RRDZYC5s9ErkjQvTvvU7keJjxUYzIISJGxm9/mAERQg=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 2 additions & 0 deletions .bingo/variables.env
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ CRD_DIFF="${GOBIN}/crd-diff-v0.2.0"

CRD_REF_DOCS="${GOBIN}/crd-ref-docs-v0.1.0"

GOJQ="${GOBIN}/gojq-v0.12.17"

GOLANGCI_LINT="${GOBIN}/golangci-lint-v2.1.6"

GORELEASER="${GOBIN}/goreleaser-v1.26.2"
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ generate: $(CONTROLLER_GEN) #EXHELP Generate code containing DeepCopy, DeepCopyI
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS) object:headerFile="hack/boilerplate.go.txt" paths="./..."

.PHONY: verify
verify: k8s-pin kind-verify-versions fmt generate manifests crd-ref-docs #HELP Verify all generated code is up-to-date. Runs k8s-pin instead of just tidy.
verify: k8s-pin kind-verify-versions fmt generate manifests update-tls-profiles crd-ref-docs #HELP Verify all generated code is up-to-date. Runs k8s-pin instead of just tidy.
git diff --exit-code

.PHONY: fix-lint
Expand All @@ -189,6 +189,10 @@ fix-lint: $(GOLANGCI_LINT) #EXHELP Fix lint issues
fmt: #EXHELP Formats code
go fmt ./...

.PHONY: update-tls-profiles
update-tls-profiles: $(GOJQ) #EXHELP Update TLS profiles from the Mozilla wiki
env JQ=$(GOJQ) hack/tools/update-tls-profiles.sh

.PHONY: verify-crd-compatibility
CRD_DIFF_ORIGINAL_REF := git://main?path=
CRD_DIFF_UPDATED_REF := file://
Expand Down
10 changes: 9 additions & 1 deletion cmd/catalogd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import (
imageutil "github.com/operator-framework/operator-controller/internal/shared/util/image"
"github.com/operator-framework/operator-controller/internal/shared/util/pullsecretcache"
sautil "github.com/operator-framework/operator-controller/internal/shared/util/sa"
"github.com/operator-framework/operator-controller/internal/shared/util/tlsprofiles"
"github.com/operator-framework/operator-controller/internal/shared/version"
)

Expand Down Expand Up @@ -142,6 +143,7 @@ func init() {
klog.InitFlags(flag.CommandLine)
flags.AddGoFlagSet(flag.CommandLine)
features.CatalogdFeatureGate.AddFlag(flags)
tlsprofiles.AddFlags(flags)

utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(ocv1.AddToScheme(scheme))
Expand Down Expand Up @@ -216,12 +218,18 @@ func run(ctx context.Context) error {
// For details, see: https://github.com/kubernetes/kubernetes/issues/121197
config.NextProtos = []string{"http/1.1"}
}
tlsProfile, err := tlsprofiles.GetTLSConfigFunc()
if err != nil {
setupLog.Error(err, "failed to get TLS profile")
return err
}

// Create webhook server and configure TLS
webhookServer := crwebhook.NewServer(crwebhook.Options{
Port: cfg.webhookPort,
TLSOpts: []func(*tls.Config){
tlsOpts,
tlsProfile,
},
})

Expand All @@ -233,7 +241,7 @@ func run(ctx context.Context) error {
metricsServerOptions.SecureServing = true
metricsServerOptions.FilterProvider = filters.WithAuthenticationAndAuthorization

metricsServerOptions.TLSOpts = append(metricsServerOptions.TLSOpts, tlsOpts)
metricsServerOptions.TLSOpts = append(metricsServerOptions.TLSOpts, tlsOpts, tlsProfile)
} else {
// Note that the metrics server is not serving if the BindAddress is set to "0".
// Therefore, the metrics server is disabled by default. It is only enabled
Expand Down
10 changes: 10 additions & 0 deletions cmd/operator-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import (
imageutil "github.com/operator-framework/operator-controller/internal/shared/util/image"
"github.com/operator-framework/operator-controller/internal/shared/util/pullsecretcache"
sautil "github.com/operator-framework/operator-controller/internal/shared/util/sa"
"github.com/operator-framework/operator-controller/internal/shared/util/tlsprofiles"
"github.com/operator-framework/operator-controller/internal/shared/version"
)

Expand Down Expand Up @@ -166,6 +167,9 @@ func init() {
//add feature gate flags to flagset
features.OperatorControllerFeatureGate.AddFlag(flags)

//add TLS flags
tlsprofiles.AddFlags(flags)

ctrl.SetLogger(klog.NewKlogr())
}
func validateMetricsFlags() error {
Expand Down Expand Up @@ -274,6 +278,12 @@ func run() error {
// the risks. More info https://github.com/golang/go/issues/63417
config.NextProtos = []string{"http/1.1"}
})
tlsProfile, err := tlsprofiles.GetTLSConfigFunc()
if err != nil {
setupLog.Error(err, "failed to get TLS profile")
return err
}
metricsServerOptions.TLSOpts = append(metricsServerOptions.TLSOpts, tlsProfile)
} else {
// Note that the metrics server is not serving if the BindAddress is set to "0".
// Therefore, the metrics server is disabled by default. It is only enabled
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ require (
github.com/prometheus/client_golang v1.23.2
github.com/prometheus/common v0.66.1
github.com/spf13/cobra v1.10.1
github.com/spf13/pflag v1.0.10
github.com/stretchr/testify v1.11.1
go.podman.io/image/v5 v5.37.0
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b
Expand Down Expand Up @@ -199,7 +200,6 @@ require (
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/smallstep/pkcs7 v0.2.1 // indirect
github.com/spf13/cast v1.7.1 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/stefanberger/go-pkcs11uri v0.0.0-20230803200340-78284954bff6 // indirect
github.com/stoewer/go-strcase v1.3.1 // indirect
github.com/stretchr/objx v0.5.2 // indirect
Expand Down
69 changes: 69 additions & 0 deletions hack/tools/update-tls-profiles.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/env bash

set -e

if [ -z "${JQ}" ]; then
echo "JQ not defined"
exit 1
fi

OUTPUT=internal/shared/util/tlsprofiles/mozilla_data.go
INPUT=https://ssl-config.mozilla.org/guidelines/latest.json

TMPFILE="$(mktemp)"
trap 'rm -rf "$TMPFILE"' EXIT

curl -L -s ${INPUT} > ${TMPFILE}

version=$(${JQ} -r '.version' ${TMPFILE})

cat > ${OUTPUT} <<EOF
package tlsprofiles

// DO NOT EDIT, GENERATED BY ${0}
// DATA SOURCE: ${INPUT}
// DATA VERSION: ${version}

import (
"crypto/tls"
)
EOF

function generate_profile {
cat >> ${OUTPUT} <<EOF

var ${1}TLSProfile = tlsProfile{
ciphers: cipherSlice{
cipherNums: []uint16{
EOF

${JQ} -r ".configurations.$1.ciphersuites.[] | . |= \"tls.\" + . + \",\"" ${TMPFILE} >> ${OUTPUT}
${JQ} -r ".configurations.$1.ciphers.go[] | . |= \"tls.\" + . + \",\"" ${TMPFILE} >> ${OUTPUT}

cat >> ${OUTPUT} <<EOF
},
},
curves: curveSlice{
curveNums: []tls.CurveID{
EOF

${JQ} -r ".configurations.$1.tls_curves[] | . |= . + \",\"" ${TMPFILE} >> ${OUTPUT}

version=$(${JQ} -r ".configurations.$1.tls_versions[0]" ${TMPFILE})
version=${version/TLSv1./tls.VersionTLS1}
version=${version/TLSv1/tls.VersionTLS10}

cat >> ${OUTPUT} <<EOF
},
},
minTLSVersion: ${version},
}
EOF
}

generate_profile "modern"
generate_profile "intermediate"
generate_profile "old"

# Make go happy
go fmt ${OUTPUT}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ spec:
- --v=${LOG_VERBOSITY}
- --global-pull-secret=openshift-config/pull-secret
{{- end }}
{{- if .Values.options.e2e.enabled }}
{{- /* This is effectively modern with the CHACHA cipher and secp384r1 curve removed */}}
- --tls-profile=custom
- --tls-custom-version=TLSv1.3
- --tls-custom-curves=X25519,prime256v1
- --tls-custom-ciphers=TLS_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384
{{- end }}
command:
- ./catalogd
{{- if or .Values.options.e2e.enabled .Values.options.openshift.enabled }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ spec:
- --v=${LOG_VERBOSITY}
- --global-pull-secret=openshift-config/pull-secret
{{- end }}
{{- if .Values.options.e2e.enabled }}
- --tls-profile=modern
{{- end }}
command:
- /operator-controller
{{- if or .Values.options.e2e.enabled .Values.options.openshift.enabled }}
Expand Down
Loading
Loading