Skip to content

Commit 121c75f

Browse files
committed
Update default minimum TLS version to 1.3
This updates the eventingtls package to use TLS 1.3 as the default minimum version, aligning with the default behavior of `knative.dev/pkg/network/tls`. The fallback to TLS 1.2 and the associated TODO have been removed. Additionally, tests asserting the default MinVersion have been removed from `pkg/eventingtls` and `cmd/requestreply`, as this configuration is now handled entirely by the underlying `knative.dev/pkg/network/tls` utility. Signed-off-by: Mikhail Fedosin <mfedosin@redhat.com>
1 parent 193eda4 commit 121c75f

File tree

3 files changed

+2
-48
lines changed

3 files changed

+2
-48
lines changed

cmd/requestreply/main_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ limitations under the License.
1717
package main
1818

1919
import (
20-
"crypto/tls"
2120
"testing"
2221

2322
reconcilertesting "knative.dev/pkg/reconciler/testing"
@@ -41,10 +40,6 @@ func TestGetServerTLSConfig(t *testing.T) {
4140
t.Fatal("expected non-nil TLS config")
4241
}
4342

44-
if tlsConfig.MinVersion != tls.VersionTLS12 {
45-
t.Fatalf("want MinVersion TLS 1.2 (%d), got %d", tls.VersionTLS12, tlsConfig.MinVersion)
46-
}
47-
4843
if tlsConfig.GetCertificate == nil {
4944
t.Fatal("expected GetCertificate to be set")
5045
}

pkg/eventingtls/eventingtls.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ const (
4747
TLSKey = "tls.key"
4848
// TLSCrt is the key in the TLS secret for the public key of TLS servers
4949
TLSCrt = "tls.crt"
50-
// DefaultMinTLSVersion is the default minimum TLS version for servers and clients.
51-
DefaultMinTLSVersion = tls.VersionTLS12
5250
// SecretCACrt is the name of the CA Cert in the secret
5351
SecretCACert = "ca.crt"
5452
// IMCDispatcherServerTLSSecretName is the name of the tls secret for the imc dispatcher server
@@ -198,19 +196,13 @@ func GetTLSServerConfig(config ServerConfig) (*tls.Config, error) {
198196

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

210-
if os.Getenv(pkgtls.MinVersionEnvKey) == "" {
211-
cfg.MinVersion = DefaultMinTLSVersion
212-
}
213-
214206
return cfg, nil
215207
}
216208

pkg/eventingtls/eventingtls_test.go

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,13 @@ wSdZWoEx7ye2kUHEyRKdRGbHyJtY9YYvaROznzxqVpIqHxnRQnE/If7kcN4t/7vi
6767
CACerts: pointer.String(""),
6868
},
6969
expected: tls.Config{
70-
MinVersion: tls.VersionTLS12,
7170
RootCAs: sysCertPool,
7271
},
7372
},
7473
{
7574
name: "nil CA certs",
7675
cfg: ClientConfig{},
7776
expected: tls.Config{
78-
MinVersion: tls.VersionTLS12,
7977
RootCAs: sysCertPool,
8078
},
8179
},
@@ -85,7 +83,6 @@ wSdZWoEx7ye2kUHEyRKdRGbHyJtY9YYvaROznzxqVpIqHxnRQnE/If7kcN4t/7vi
8583
CACerts: pointer.String(pemCaCert),
8684
},
8785
expected: tls.Config{
88-
MinVersion: tls.VersionTLS12,
8986
RootCAs: WithCerts(sysCertPool, pemCaCert),
9087
},
9188
},
@@ -94,9 +91,7 @@ wSdZWoEx7ye2kUHEyRKdRGbHyJtY9YYvaROznzxqVpIqHxnRQnE/If7kcN4t/7vi
9491
cfg: ClientConfig{
9592
CACerts: pointer.String(pemCaCert[:len(pemCaCert)-30]),
9693
},
97-
expected: tls.Config{
98-
MinVersion: tls.VersionTLS12,
99-
},
94+
expected: tls.Config{},
10095
wantErr: true,
10196
},
10297
}
@@ -115,10 +110,6 @@ wSdZWoEx7ye2kUHEyRKdRGbHyJtY9YYvaROznzxqVpIqHxnRQnE/If7kcN4t/7vi
115110
if !got.RootCAs.Equal(tc.expected.RootCAs) {
116111
t.Fatalf("Got RootCAs are not equal to expected RootCAs")
117112
}
118-
119-
if got.MinVersion != tc.expected.MinVersion {
120-
t.Fatalf("want MinVersion %v, got %v", tc.expected.MinVersion, got.MinVersion)
121-
}
122113
})
123114
}
124115
}
@@ -132,18 +123,6 @@ func WithCerts(pool *x509.CertPool, caCerts string) *x509.CertPool {
132123
}
133124

134125
func TestGetTLSClientConfigEnv(t *testing.T) {
135-
t.Run("defaults to TLS 1.2 when env not set", func(t *testing.T) {
136-
t.Setenv(pkgtls.MinVersionEnvKey, "")
137-
138-
cfg, err := GetTLSClientConfig(NewDefaultClientConfig())
139-
if err != nil {
140-
t.Fatal("unexpected error:", err)
141-
}
142-
if cfg.MinVersion != tls.VersionTLS12 {
143-
t.Fatalf("want MinVersion TLS 1.2 (%d), got %d", tls.VersionTLS12, cfg.MinVersion)
144-
}
145-
})
146-
147126
t.Run("uses TLS 1.3 when explicitly set via env", func(t *testing.T) {
148127
t.Setenv(pkgtls.MinVersionEnvKey, "1.3")
149128

@@ -206,18 +185,6 @@ func TestGetTLSClientConfigEnv(t *testing.T) {
206185
}
207186

208187
func TestGetTLSServerConfig(t *testing.T) {
209-
t.Run("defaults to TLS 1.2 when env not set", func(t *testing.T) {
210-
t.Setenv(pkgtls.MinVersionEnvKey, "")
211-
212-
cfg, err := GetTLSServerConfig(NewDefaultServerConfig())
213-
if err != nil {
214-
t.Fatal("unexpected error:", err)
215-
}
216-
if cfg.MinVersion != tls.VersionTLS12 {
217-
t.Fatalf("want MinVersion TLS 1.2 (%d), got %d", tls.VersionTLS12, cfg.MinVersion)
218-
}
219-
})
220-
221188
t.Run("uses TLS 1.3 when explicitly set via env", func(t *testing.T) {
222189
t.Setenv(pkgtls.MinVersionEnvKey, "1.3")
223190

0 commit comments

Comments
 (0)