Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit 0582092

Browse files
whitneygriffithjaellio
authored andcommitted
fix(): reduce minimum tls version for osm controller, verifier, health (#5292)
Addresses potentially incompatible envoy max tls version and OSM control plane min tls version by updating the OSM control plane min tls version from TLSv1_3 to TLSv1_2. Fixes #5282. Signed-off-by: Whitney Griffith <[email protected]> Signed-off-by: jaellio <[email protected]>
1 parent 4520b20 commit 0582092

File tree

3 files changed

+164
-2
lines changed

3 files changed

+164
-2
lines changed

pkg/health/health.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (httpProbe HTTPProbe) Probe() (int, error) {
5050
transport := &http.Transport{
5151
TLSClientConfig: &tls.Config{
5252
InsecureSkipVerify: true,
53-
MinVersion: tls.VersionTLS13,
53+
MinVersion: tls.VersionTLS12,
5454
},
5555
}
5656
client.Transport = transport

pkg/utils/mtls.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func setupMutualTLS(insecure bool, serverName string, certPem []byte, keyPem []b
3535
ClientAuth: tls.RequireAndVerifyClientCert,
3636
Certificates: []tls.Certificate{certif},
3737
ClientCAs: certPool,
38-
MinVersion: tls.VersionTLS13,
38+
MinVersion: tls.VersionTLS12,
3939
}
4040
return grpc.Creds(credentials.NewTLS(&tlsConfig)), nil
4141
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
package e2e
2+
3+
import (
4+
"fmt"
5+
"strings"
6+
"time"
7+
8+
. "github.com/onsi/ginkgo"
9+
. "github.com/onsi/gomega"
10+
v1 "k8s.io/api/core/v1"
11+
12+
. "github.com/openservicemesh/osm/tests/framework"
13+
)
14+
15+
// Prior iterations of OSM supported a wide range of min and max MTLS versions for the envoy sidecar (TLS_AUTO, TLSv1_0, TLSv1_1, TLSv1_2 and TLSv1_3)
16+
// even though the OSM Control Plane's minimum version has been upgraded to TLSv1_2
17+
// This test verifies that the envoy sidecar maxTLSVersion is compatible with the current osm control plane's minTLSVersion
18+
var _ = OSMDescribe("Test envoy maxTLSVersion is compatible with osm control plane's minTLSVersion",
19+
OSMDescribeInfo{
20+
Tier: 1,
21+
Bucket: 12,
22+
},
23+
func() {
24+
Context("Envoy maxTLSVersion equals control planes's minTLSVersion, tls.VersionTLS12", func() {
25+
// Is compatible
26+
envoyMaxTLSVersion := "TLSv1_2"
27+
testEnvoyMaxMtlsVersionIsCompatibileWithOSMControlPlane(envoyMaxTLSVersion)
28+
})
29+
30+
Context("envoy maxTLSVersion is greater than the control planes's minTLSVersion, tls.VersionTLS13", func() {
31+
// Is compatible
32+
envoyMaxTLSVersion := "TLSv1_3"
33+
testEnvoyMaxMtlsVersionIsCompatibileWithOSMControlPlane(envoyMaxTLSVersion)
34+
})
35+
36+
Context("envoy maxTLSVersion is less than the control planes's minTLSVersion, tls.VersionTLS11", func() {
37+
// Is not compatible
38+
envoyMaxTLSVersion := "TLSv1_1"
39+
testEnvoyMaxMtlsVersionIsNotCompatibileWithOSMControlPlane(envoyMaxTLSVersion)
40+
})
41+
})
42+
43+
func testEnvoyMaxMtlsVersionIsCompatibileWithOSMControlPlane(envoyMaxTLSVersion string) {
44+
const clientName = "client"
45+
const serverName = "server"
46+
var ns = []string{clientName, serverName}
47+
48+
It("Tests HTTP traffic for client pod -> server pod", func() {
49+
// Set up meshed client and server pods
50+
clientPod, dstSvc := setUpTestApps(envoyMaxTLSVersion, clientName, serverName, ns)
51+
52+
By("Sending a request from client to server")
53+
// All ready. Expect client to reach server
54+
clientToServer := HTTPRequestDef{
55+
SourceNs: clientName,
56+
SourcePod: clientPod.Name,
57+
SourceContainer: clientName,
58+
59+
Destination: fmt.Sprintf("%s.%s.svc.cluster.local", dstSvc.Name, dstSvc.Namespace),
60+
}
61+
62+
srcToDestStr := fmt.Sprintf("%s -> %s",
63+
fmt.Sprintf("%s/%s", clientName, clientPod.Name),
64+
clientToServer.Destination)
65+
66+
cond := Td.WaitForRepeatedSuccess(func() bool {
67+
result := Td.HTTPRequest(clientToServer)
68+
if result.Err != nil || result.StatusCode != 200 {
69+
Td.T.Logf("> (%s) HTTP Req failed %d %v",
70+
srcToDestStr, result.StatusCode, result.Err)
71+
return false
72+
}
73+
Td.T.Logf("> (%s) HTTP Req succeeded: %d", srcToDestStr, result.StatusCode)
74+
return true
75+
}, 5, Td.ReqSuccessTimeout)
76+
Expect(cond).To(BeTrue(), "envoy maxTLSVersion %s is compatible with osm control plane", envoyMaxTLSVersion)
77+
})
78+
}
79+
80+
func testEnvoyMaxMtlsVersionIsNotCompatibileWithOSMControlPlane(envoyMaxTLSVersion string) {
81+
const clientName = "client"
82+
const serverName = "server"
83+
var ns = []string{clientName, serverName}
84+
85+
It("Tests HTTP traffic for client pod -> server pod", func() {
86+
// Set up meshed client and server pods
87+
clientPod, dstSvc := setUpTestApps(envoyMaxTLSVersion, clientName, serverName, ns)
88+
89+
By("Sending a request from client to server")
90+
// All ready. Expect client to reach server
91+
clientToServer := HTTPRequestDef{
92+
SourceNs: clientName,
93+
SourcePod: clientPod.Name,
94+
SourceContainer: clientName,
95+
96+
Destination: fmt.Sprintf("%s.%s.svc.cluster.local", dstSvc.Name, dstSvc.Namespace),
97+
}
98+
99+
srcToDestStr := fmt.Sprintf("%s -> %s",
100+
fmt.Sprintf("%s/%s", clientName, clientPod.Name),
101+
clientToServer.Destination)
102+
103+
cond := Td.WaitForRepeatedSuccess(func() bool {
104+
result := Td.HTTPRequest(clientToServer)
105+
// Curl exit code 7 == Conn refused
106+
if result.Err == nil || !strings.Contains(result.Err.Error(), "command terminated with exit code 7 ") {
107+
Td.T.Logf("> (%s) HTTP Req failed, incorrect expected result: %d, %v", srcToDestStr, result.StatusCode, result.Err)
108+
return false
109+
}
110+
Td.T.Logf("> (%s) HTTP Req failed correctly: %v", srcToDestStr, result.Err)
111+
return true
112+
}, 5, 150*time.Second)
113+
Expect(cond).To(BeTrue(), "envoy maxTLSVersion %s is not compatible with osm control plane", envoyMaxTLSVersion)
114+
})
115+
}
116+
117+
// setUpTestApps creates a curl client pod, http server pod and kubernetes service for server pod
118+
func setUpTestApps(envoyMaxTLSVersion string, clientName string, serverName string, ns []string) (*v1.Pod, *v1.Service) {
119+
// Install OSM
120+
installOpts := Td.GetOSMInstallOpts()
121+
installOpts.EnablePermissiveMode = true
122+
Expect(Td.InstallOSM(installOpts)).To(Succeed())
123+
Expect(Td.WaitForPodsRunningReady(Td.OsmNamespace, 60*time.Second, 3 /* 1 controller, 1 injector, 1 bootstrap */, nil)).To(Succeed())
124+
125+
// Get the meshConfig CRD
126+
meshConfig, err := Td.GetMeshConfig(Td.OsmNamespace)
127+
Expect(err).NotTo(HaveOccurred())
128+
129+
// Update envoy maxTLSVersion
130+
By(fmt.Sprintf("Patching envoy maxTLSVersion to be %s", envoyMaxTLSVersion))
131+
meshConfig.Spec.Sidecar.TLSMaxProtocolVersion = envoyMaxTLSVersion
132+
_, err = Td.UpdateOSMConfig(meshConfig)
133+
Expect(err).NotTo(HaveOccurred())
134+
135+
// Create Meshed Test NS
136+
for _, n := range ns {
137+
Expect(Td.CreateNs(n, nil)).To(Succeed())
138+
Expect(Td.AddNsToMesh(true, n)).To(Succeed())
139+
}
140+
141+
// Get simple pod definitions for the HTTP server
142+
svcAccDef, podDef, svcDef, err := Td.GetOSSpecificHTTPBinPod(serverName, serverName, PodCommandDefault...)
143+
Expect(err).NotTo(HaveOccurred())
144+
145+
// Create Server Pod
146+
_, err = Td.CreateServiceAccount(serverName, &svcAccDef)
147+
Expect(err).NotTo(HaveOccurred())
148+
_, err = Td.CreatePod(serverName, podDef)
149+
Expect(err).NotTo(HaveOccurred())
150+
151+
// Create Server Service
152+
dstSvc, err := Td.CreateService(serverName, svcDef)
153+
Expect(err).NotTo(HaveOccurred())
154+
// Expect it to be up and running in it's receiver namespace
155+
Expect(Td.WaitForPodsRunningReady(serverName, 90*time.Second, 1, nil)).To(Succeed())
156+
157+
// Create Client Pod
158+
withSourceKubernetesService := true
159+
// setupSource sets up a curl source service and returns the pod object
160+
clientPod := setupSource(clientName, withSourceKubernetesService)
161+
return clientPod, dstSvc
162+
}

0 commit comments

Comments
 (0)