Skip to content

Commit 61bdcf0

Browse files
committed
Inject operator's trust store with trusted-ca-bundle
1 parent 185cedb commit 61bdcf0

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

manifests/03_configmap.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ data:
1010
---
1111
apiVersion: v1
1212
kind: ConfigMap
13+
metadata:
14+
namespace: openshift-authentication-operator
15+
name: trusted-ca-bundle
16+
annotations:
17+
release.openshift.io/create-only: "true"
18+
labels:
19+
config.openshift.io/inject-trusted-cabundle: "true"
20+
---
21+
apiVersion: v1
22+
kind: ConfigMap
1323
metadata:
1424
namespace: openshift-authentication
1525
name: v4-0-config-trusted-ca-bundle

manifests/07_deployment.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ spec:
3636
name: config
3737
- mountPath: /var/run/secrets/serving-cert
3838
name: serving-cert
39+
- mountPath: /var/run/configmaps/trusted-ca-bundle
40+
name: trusted-ca-bundle
41+
readOnly: true
3942
env:
4043
- name: IMAGE
4144
value: quay.io/openshift/origin-oauth-server:v4.2
@@ -53,6 +56,10 @@ spec:
5356
configMap:
5457
defaultMode: 440
5558
name: authentication-operator-config
59+
- name: trusted-ca-bundle
60+
configMap:
61+
name: trusted-ca-bundle
62+
optional: true
5663
- name: serving-cert
5764
secret:
5865
secretName: serving-cert

pkg/operator2/idp.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package operator2
33
import (
44
"encoding/json"
55
"fmt"
6+
"io/ioutil"
67
"net/http"
78
"net/url"
89
"strings"
@@ -293,7 +294,7 @@ func (c *authOperator) discoverOpenIDURLs(issuer, key string, ca configv1.Config
293294

294295
func (c *authOperator) transportForCARef(ca configv1.ConfigMapNameReference, key string) (http.RoundTripper, error) {
295296
if len(ca.Name) == 0 {
296-
return transportFor("", nil, nil, nil)
297+
return transportForTrustedCA("", nil, nil)
297298
}
298299
cm, err := c.configMaps.ConfigMaps(userConfigNamespace).Get(ca.Name, metav1.GetOptions{})
299300
if err != nil {
@@ -343,3 +344,12 @@ func encodeOrDie(obj runtime.Object) []byte {
343344
}
344345
return bytes
345346
}
347+
348+
func transportForTrustedCA(serverName string, certData []byte, keyData []byte) (http.RoundTripper, error) {
349+
caData, err := ioutil.ReadFile(operatorTrustedCAFile)
350+
if err != nil {
351+
return nil, fmt.Errorf("failed to read %s: %v", operatorTrustedCAFile, err)
352+
}
353+
354+
return transportFor(serverName, caData, certData, keyData)
355+
}

pkg/operator2/operator.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ const (
6262
kasServiceAndEndpointName = "kubernetes"
6363
kasServiceFullName = kasServiceAndEndpointName + "." + corev1.NamespaceDefault + ".svc"
6464

65-
rootCAFile = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
65+
rootCAFile = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
66+
operatorTrustedCAFile = "/var/run/configmaps/trusted-ca-bundle/ca-bundle.crt"
6667

6768
systemTrustStoreDirPath = "/etc/pki/ca-trust/extracted/pem"
6869

0 commit comments

Comments
 (0)