Skip to content

Commit 74da43e

Browse files
committed
Inject operator's trust store with trusted-ca-bundle
1 parent 1c00a9d commit 74da43e

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
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: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ package operator2
33
import (
44
"encoding/json"
55
"fmt"
6+
"io/ioutil"
67
"net/http"
78
"net/url"
9+
"path"
810
"strings"
911

1012
corev1 "k8s.io/api/core/v1"
@@ -293,7 +295,7 @@ func (c *authOperator) discoverOpenIDURLs(issuer, key string, ca configv1.Config
293295

294296
func (c *authOperator) transportForCARef(ca configv1.ConfigMapNameReference, key string) (http.RoundTripper, error) {
295297
if len(ca.Name) == 0 {
296-
return transportFor("", nil, nil, nil)
298+
return transportForTrustedCA("", nil, nil)
297299
}
298300
cm, err := c.configMaps.ConfigMaps(userConfigNamespace).Get(ca.Name, metav1.GetOptions{})
299301
if err != nil {
@@ -343,3 +345,13 @@ func encodeOrDie(obj runtime.Object) []byte {
343345
}
344346
return bytes
345347
}
348+
349+
func transportForTrustedCA(serverName string, certData []byte, keyData []byte) (http.RoundTripper, error) {
350+
trustedBundlePath := path.Join(trustedCABundleMountDir, "ca-bundle.crt")
351+
caData, err := ioutil.ReadFile(trustedBundlePath)
352+
if err != nil {
353+
return nil, fmt.Errorf("failed to read %s: %v", trustedBundlePath, err)
354+
}
355+
356+
return transportFor(serverName, caData, certData, keyData)
357+
}

0 commit comments

Comments
 (0)