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: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ require (
k8s.io/api v0.35.2
k8s.io/apimachinery v0.35.2
k8s.io/client-go v0.35.2
knative.dev/client/pkg v0.0.0-20260310143814-8342632107e5
knative.dev/client/pkg v0.0.0-20260311023114-f035c02eaa46
knative.dev/hack v0.0.0-20260310014051-c448fdb867e2
knative.dev/networking v0.0.0-20260310141215-8340ed7fd0e1
knative.dev/serving v0.48.1-0.20260310211214-d686bb2b8684
knative.dev/serving v0.48.1-0.20260311135821-f8e91a05ce79
)

require (
Expand Down Expand Up @@ -104,7 +104,7 @@ require (
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 // indirect
knative.dev/eventing v0.48.1-0.20260310120613-104b6237f845 // indirect
knative.dev/eventing v0.48.1-0.20260310212212-60fa543deb11 // indirect
knative.dev/pkg v0.0.0-20260310013839-5504026dd1b6 // indirect
sigs.k8s.io/gateway-api v1.1.0 // indirect
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -303,18 +303,18 @@ k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 h1:Y3gxNAuB0OBLImH611+UDZ
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912/go.mod h1:kdmbQkyfwUagLfXIad1y2TdrjPFWp2Q89B3qkRwf/pQ=
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 h1:SjGebBtkBqHFOli+05xYbK8YF1Dzkbzn+gDM4X9T4Ck=
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
knative.dev/client/pkg v0.0.0-20260310143814-8342632107e5 h1:RPzJ8qcg5h+jyqpA405TqZ9ihyldS4HC3NkrG5WjUFk=
knative.dev/client/pkg v0.0.0-20260310143814-8342632107e5/go.mod h1:PXr4AWXN7zHoK08QV6DCDXi5RbO5OxHFV1MMtZwKkyw=
knative.dev/eventing v0.48.1-0.20260310120613-104b6237f845 h1:i6Dhhq07M5qqgRaYQ1aTcnpAnPGHPMoyd41bc9Dy7UI=
knative.dev/eventing v0.48.1-0.20260310120613-104b6237f845/go.mod h1:nn4erf/DV7kg4qlIjz00JJjqqP6X58PaETGjDgbY8Jo=
knative.dev/client/pkg v0.0.0-20260311023114-f035c02eaa46 h1:XZNod773abFvuMJsQ2M3+AXIsyvHqGd0/gqiDMcLJeY=
knative.dev/client/pkg v0.0.0-20260311023114-f035c02eaa46/go.mod h1:tHLgww7ONbLylf3pFLfUiGY562cR6KFG9veDF9AH4MU=
knative.dev/eventing v0.48.1-0.20260310212212-60fa543deb11 h1:e/PDnLDTeZ1TE60JSlrbg/yu3XnIF7EdWeMh/FMBMXU=
knative.dev/eventing v0.48.1-0.20260310212212-60fa543deb11/go.mod h1:nn4erf/DV7kg4qlIjz00JJjqqP6X58PaETGjDgbY8Jo=
knative.dev/hack v0.0.0-20260310014051-c448fdb867e2 h1:b35SGLEp03D8oGf8mE9HBt3yfNgYpAK0fw46hFXs9w4=
knative.dev/hack v0.0.0-20260310014051-c448fdb867e2/go.mod h1:L5RzHgbvam0u8QFHfzCX6MKxu/a/gIGEdaRBqNiVbl0=
knative.dev/networking v0.0.0-20260310141215-8340ed7fd0e1 h1:MA7om/7ZLLj7dXmaHTUCoGOgd8AfCCdsKvBPBhPtisg=
knative.dev/networking v0.0.0-20260310141215-8340ed7fd0e1/go.mod h1:72PhQ+qnOAwz9FFK8y301eWuiQ6vD9qVUFnDBjNhju8=
knative.dev/pkg v0.0.0-20260310013839-5504026dd1b6 h1:oVpQ0Y+FUmRQer8kdqJjQL20KveZa5sCfnBWeJi4nyQ=
knative.dev/pkg v0.0.0-20260310013839-5504026dd1b6/go.mod h1:ziEj0TQOWvBw7t/VSkqaZlv++Qk8FfiuI72ZDmv23nI=
knative.dev/serving v0.48.1-0.20260310211214-d686bb2b8684 h1:rm/iRB2+Gn2C98rZHF8JkmU8Eduvbk+2CrejLWvoYUU=
knative.dev/serving v0.48.1-0.20260310211214-d686bb2b8684/go.mod h1:jdUcDEFlVNOSNTI03zKqx92BIT9Sh+mK0tlZCobXhrs=
knative.dev/serving v0.48.1-0.20260311135821-f8e91a05ce79 h1:7ij6hSu2Qu5NCH9DIv7OhNG6mtrq0xwJPZkwXtwHV4w=
knative.dev/serving v0.48.1-0.20260311135821-f8e91a05ce79/go.mod h1:jdUcDEFlVNOSNTI03zKqx92BIT9Sh+mK0tlZCobXhrs=
sigs.k8s.io/gateway-api v1.1.0 h1:DsLDXCi6jR+Xz8/xd0Z1PYl2Pn0TyaFMOPPZIj4inDM=
sigs.k8s.io/gateway-api v1.1.0/go.mod h1:ZH4lHrL2sDi0FHZ9jjneb8kKnGzFWyrTya35sWUTrRs=
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg=
Expand Down
43 changes: 35 additions & 8 deletions vendor/knative.dev/eventing/pkg/eventingtls/eventingtls.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
duckv1 "knative.dev/pkg/apis/duck/v1"
"knative.dev/pkg/controller"
"knative.dev/pkg/logging"
pkgtls "knative.dev/pkg/tls"
)

const (
Expand All @@ -58,6 +59,8 @@ const (
BrokerFilterServerTLSSecretName = "mt-broker-filter-server-tls" //nolint:gosec // This is not a hardcoded credential
// BrokerIngressServerTLSSecretName is the name of the tls secret for the broker ingress server
BrokerIngressServerTLSSecretName = "mt-broker-ingress-server-tls" //nolint:gosec // This is not a hardcoded credential
// RequestReplyServerTLSSecretName is the name of the tls secret for the request reply server
RequestReplyServerTLSSecretName = "request-reply-server-tls" //nolint:gosec // This is not a hardcoded credential
)

type ClientConfig struct {
Expand Down Expand Up @@ -170,21 +173,45 @@ func GetTLSClientConfig(config ClientConfig) (*tls.Config, error) {
return nil, err
}

return &tls.Config{
RootCAs: pool,
MinVersion: DefaultMinTLSVersion,
}, nil
cfg, err := defaultTLSConfigFromEnv()
if err != nil {
return nil, err
}

cfg.RootCAs = pool
return cfg, nil
}

func NewDefaultServerConfig() ServerConfig {
return ServerConfig{}
}

func GetTLSServerConfig(config ServerConfig) (*tls.Config, error) {
return &tls.Config{
MinVersion: DefaultMinTLSVersion,
GetCertificate: config.GetCertificate,
}, nil
cfg, err := defaultTLSConfigFromEnv()
if err != nil {
return nil, err
}

cfg.GetCertificate = config.GetCertificate
return cfg, nil
}

// defaultTLSConfigFromEnv loads TLS configuration from environment variables
// using the shared knative/pkg/tls utility. DefaultConfigFromEnv defaults to
// TLS 1.3, but eventing historically defaults to TLS 1.2, so we fall back to
// 1.2 unless TLS_MIN_VERSION is explicitly set.
// TODO: switch to TLS 1.3 to align with the rest of the system.
func defaultTLSConfigFromEnv() (*tls.Config, error) {
cfg, err := pkgtls.DefaultConfigFromEnv("")
if err != nil {
return nil, fmt.Errorf("failed to load TLS config from env: %w", err)
}

if os.Getenv(pkgtls.MinVersionEnvKey) == "" {
cfg.MinVersion = DefaultMinTLSVersion
}

return cfg, nil
}

// IsHttpsSink returns true if the sink has scheme equal to https.
Expand Down
156 changes: 156 additions & 0 deletions vendor/knative.dev/pkg/network/tls/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
/*
Copyright 2026 The Knative Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package tls

import (
cryptotls "crypto/tls"
"fmt"
"os"
"strings"
)

// Environment variable name suffixes for TLS configuration.
// Use with a prefix to namespace them, e.g. "WEBHOOK_" + MinVersionEnvKey
// reads the WEBHOOK_TLS_MIN_VERSION variable.
const (
MinVersionEnvKey = "TLS_MIN_VERSION"
MaxVersionEnvKey = "TLS_MAX_VERSION"
CipherSuitesEnvKey = "TLS_CIPHER_SUITES"
CurvePreferencesEnvKey = "TLS_CURVE_PREFERENCES"
)

// DefaultConfigFromEnv returns a tls.Config with secure defaults.
// The prefix is prepended to each standard env-var suffix;
// for example with prefix "WEBHOOK_" the function reads
// WEBHOOK_TLS_MIN_VERSION, WEBHOOK_TLS_MAX_VERSION, etc.
func DefaultConfigFromEnv(prefix string) (*cryptotls.Config, error) {
cfg := &cryptotls.Config{
MinVersion: cryptotls.VersionTLS13,
}

if v := os.Getenv(prefix + MinVersionEnvKey); v != "" {
ver, err := parseVersion(v)
if err != nil {
return nil, fmt.Errorf("invalid %s%s %q: %w", prefix, MinVersionEnvKey, v, err)
}
cfg.MinVersion = ver
}

if v := os.Getenv(prefix + MaxVersionEnvKey); v != "" {
ver, err := parseVersion(v)
if err != nil {
return nil, fmt.Errorf("invalid %s%s %q: %w", prefix, MaxVersionEnvKey, v, err)
}
cfg.MaxVersion = ver
}

if v := os.Getenv(prefix + CipherSuitesEnvKey); v != "" {
suites, err := parseCipherSuites(v)
if err != nil {
return nil, fmt.Errorf("invalid %s%s: %w", prefix, CipherSuitesEnvKey, err)
}
cfg.CipherSuites = suites
}

if v := os.Getenv(prefix + CurvePreferencesEnvKey); v != "" {
curves, err := parseCurvePreferences(v)
if err != nil {
return nil, fmt.Errorf("invalid %s%s: %w", prefix, CurvePreferencesEnvKey, err)
}
cfg.CurvePreferences = curves
}

return cfg, nil
}

// parseVersion converts a TLS version string to the corresponding
// crypto/tls constant. Accepted values are "1.2" and "1.3".
func parseVersion(v string) (uint16, error) {
switch v {
case "1.2":
return cryptotls.VersionTLS12, nil
case "1.3":
return cryptotls.VersionTLS13, nil
default:
return 0, fmt.Errorf("unsupported TLS version %q: must be %q or %q", v, "1.2", "1.3")
}
}

// parseCipherSuites parses a comma-separated list of TLS cipher-suite names
// (e.g. "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384")
// into a slice of cipher-suite IDs. Names must match those returned by
// crypto/tls.CipherSuiteName.
func parseCipherSuites(s string) ([]uint16, error) {
lookup := cipherSuiteLookup()
parts := strings.Split(s, ",")
suites := make([]uint16, 0, len(parts))

for _, name := range parts {
name = strings.TrimSpace(name)
if name == "" {
continue
}
id, ok := lookup[name]
if !ok {
return nil, fmt.Errorf("unknown cipher suite %q", name)
}
suites = append(suites, id)
}

return suites, nil
}

// parseCurvePreferences parses a comma-separated list of elliptic-curve names
// (e.g. "X25519,CurveP256") into a slice of crypto/tls.CurveID values.
// Both Go constant names (CurveP256) and standard names (P-256) are accepted.
func parseCurvePreferences(s string) ([]cryptotls.CurveID, error) {
parts := strings.Split(s, ",")
curves := make([]cryptotls.CurveID, 0, len(parts))

for _, name := range parts {
name = strings.TrimSpace(name)
if name == "" {
continue
}
id, ok := curvesByName[name]
if !ok {
return nil, fmt.Errorf("unknown curve %q", name)
}
curves = append(curves, id)
}

return curves, nil
}

func cipherSuiteLookup() map[string]uint16 {
m := make(map[string]uint16)
for _, cs := range cryptotls.CipherSuites() {
m[cs.Name] = cs.ID
}
return m
}

var curvesByName = map[string]cryptotls.CurveID{
"CurveP256": cryptotls.CurveP256,
"CurveP384": cryptotls.CurveP384,
"CurveP521": cryptotls.CurveP521,
"X25519": cryptotls.X25519,
"X25519MLKEM768": cryptotls.X25519MLKEM768,
"P-256": cryptotls.CurveP256,
"P-384": cryptotls.CurveP384,
"P-521": cryptotls.CurveP521,
}
39 changes: 39 additions & 0 deletions vendor/knative.dev/pkg/tls/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright 2026 The Knative Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Deprecated: Use knative.dev/pkg/network/tls instead.
// This package is kept for backward compatibility and re-exports all
// public symbols from knative.dev/pkg/network/tls.
package tls

import (
networktls "knative.dev/pkg/network/tls"
)

// Deprecated: Use knative.dev/pkg/network/tls.MinVersionEnvKey instead.
const MinVersionEnvKey = networktls.MinVersionEnvKey

// Deprecated: Use knative.dev/pkg/network/tls.MaxVersionEnvKey instead.
const MaxVersionEnvKey = networktls.MaxVersionEnvKey

// Deprecated: Use knative.dev/pkg/network/tls.CipherSuitesEnvKey instead.
const CipherSuitesEnvKey = networktls.CipherSuitesEnvKey

// Deprecated: Use knative.dev/pkg/network/tls.CurvePreferencesEnvKey instead.
const CurvePreferencesEnvKey = networktls.CurvePreferencesEnvKey

// Deprecated: Use knative.dev/pkg/network/tls.DefaultConfigFromEnv instead.
var DefaultConfigFromEnv = networktls.DefaultConfigFromEnv
8 changes: 5 additions & 3 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ k8s.io/utils/net
k8s.io/utils/pointer
k8s.io/utils/ptr
k8s.io/utils/trace
# knative.dev/client/pkg v0.0.0-20260310143814-8342632107e5
# knative.dev/client/pkg v0.0.0-20260311023114-f035c02eaa46
## explicit; go 1.25.0
knative.dev/client/pkg/apis/client
knative.dev/client/pkg/apis/client/v1alpha1
Expand All @@ -952,7 +952,7 @@ knative.dev/client/pkg/util/errors
knative.dev/client/pkg/util/mock
knative.dev/client/pkg/util/test
knative.dev/client/pkg/wait
# knative.dev/eventing v0.48.1-0.20260310120613-104b6237f845
# knative.dev/eventing v0.48.1-0.20260310212212-60fa543deb11
## explicit; go 1.25.0
knative.dev/eventing/pkg/apis/common/integration/v1alpha1
knative.dev/eventing/pkg/apis/config
Expand Down Expand Up @@ -1026,6 +1026,7 @@ knative.dev/pkg/leaderelection
knative.dev/pkg/logging
knative.dev/pkg/logging/logkey
knative.dev/pkg/network
knative.dev/pkg/network/tls
knative.dev/pkg/observability/attributekey
knative.dev/pkg/observability/metrics/k8s
knative.dev/pkg/observability/runtime
Expand All @@ -1042,8 +1043,9 @@ knative.dev/pkg/test/environment
knative.dev/pkg/test/ingress
knative.dev/pkg/test/logging
knative.dev/pkg/test/spoof
knative.dev/pkg/tls
knative.dev/pkg/tracker
# knative.dev/serving v0.48.1-0.20260310211214-d686bb2b8684
# knative.dev/serving v0.48.1-0.20260311135821-f8e91a05ce79
## explicit; go 1.25.0
knative.dev/serving/pkg/apis/autoscaling
knative.dev/serving/pkg/apis/autoscaling/v1alpha1
Expand Down
Loading