Skip to content

Commit 947f8e7

Browse files
concaftekton-robot
authored andcommitted
Treat SSL_CERT_DIR as a colon separated list
Prior to this commit, we used to treat SSL_CERT_DIR as a string containing one directory but it is/can be a colon separated list of directories. This commit fixes that assumption.
1 parent aec80b0 commit 947f8e7

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

pkg/reconciler/openshift/common/cabundle.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package common
1919
import (
2020
"encoding/json"
2121
"path/filepath"
22+
"strings"
2223

2324
appsv1 "k8s.io/api/apps/v1"
2425
corev1 "k8s.io/api/core/v1"
@@ -125,14 +126,16 @@ func ApplyCABundles(u *unstructured.Unstructured) error {
125126
// Let's mount the certificates now.
126127
volumeMounts = append(volumeMounts,
127128
corev1.VolumeMount{
128-
Name: trustedCAConfigMapVolume,
129-
MountPath: filepath.Join(sslCertDir, trustedCAKey),
129+
Name: trustedCAConfigMapVolume,
130+
// We only want the first entry in SSL_CERT_DIR for the mount
131+
MountPath: filepath.Join(strings.Split(sslCertDir, ":")[0], trustedCAKey),
130132
SubPath: trustedCAKey,
131133
ReadOnly: true,
132134
},
133135
corev1.VolumeMount{
134-
Name: serviceCAConfigMapVolume,
135-
MountPath: filepath.Join(sslCertDir, serviceCAKey),
136+
Name: serviceCAConfigMapVolume,
137+
// We only want the first entry in SSL_CERT_DIR for the mount
138+
MountPath: filepath.Join(strings.Split(sslCertDir, ":")[0], serviceCAKey),
136139
SubPath: serviceCAKey,
137140
ReadOnly: true,
138141
},

pkg/reconciler/proxy/proxy.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -429,24 +429,28 @@ func updateVolume(pod corev1.Pod, volumeName, configmapName, key string) corev1.
429429
//
430430
// Copied from https://golang.org/src/crypto/x509/root_linux.go
431431
var certDirectories = []string{
432+
// Ordering is important here - we will be using the "first"
433+
// element in SSL_CERT_DIR to do the volume mounts.
432434
sslCertDir, // /tekton-custom-certs
433435
"/etc/ssl/certs", // SLES10/SLES11, https://golang.org/issue/12139
434436
"/etc/pki/tls/certs", // Fedora/RHEL
435437
"/system/etc/security/cacerts", // Android
436438
}
437439

440+
// SSL_CERT_DIR accepts a colon separated list of directories
441+
sslCertDir = strings.Join(certDirectories, ":")
438442
c.Env = append(c.Env, corev1.EnvVar{
439-
Name: "SSL_CERT_DIR",
440-
// SSL_CERT_DIR accepts a colon separated list of directories
441-
Value: strings.Join(certDirectories, ":"),
443+
Name: "SSL_CERT_DIR",
444+
Value: sslCertDir,
442445
})
443446
}
444447

445448
// Let's mount the certificates now.
446449
volumeMounts = append(volumeMounts,
447450
corev1.VolumeMount{
448-
Name: volumeName,
449-
MountPath: filepath.Join(sslCertDir, key),
451+
Name: volumeName,
452+
// We only want the first entry in SSL_CERT_DIR for the mount
453+
MountPath: filepath.Join(strings.Split(sslCertDir, ":")[0], key),
450454
SubPath: key,
451455
ReadOnly: true,
452456
},

0 commit comments

Comments
 (0)