Skip to content

Commit 03ebe5b

Browse files
committed
Inject operator's trust store with trusted-ca-bundle
1 parent 8649f95 commit 03ebe5b

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
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: 10 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: /etc/pki/ca-trust/extracted/pem
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,13 @@ spec:
5356
configMap:
5457
defaultMode: 440
5558
name: authentication-operator-config
59+
- name: trusted-ca-bundle
60+
configMap:
61+
name: trusted-ca
62+
optional: true
63+
items:
64+
- key: ca-bundle.crt
65+
path: tls-ca-bundle.pem
5666
- name: serving-cert
5767
secret:
5868
secretName: serving-cert

pkg/operator2/transport.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,27 @@ func transportFor(serverName string, caData, certData, keyData []byte) (http.Rou
2222
}
2323

2424
func transportForInner(serverName string, caData, certData, keyData []byte) (http.RoundTripper, error) {
25-
if len(caData) == 0 && len(certData) == 0 && len(keyData) == 0 {
26-
return http.DefaultTransport, nil
27-
}
28-
29-
if (len(certData) == 0) != (len(keyData) == 0) {
30-
return nil, errors.New("cert and key data must be specified together")
31-
}
32-
3325
// copy default transport
3426
transport := net.SetTransportDefaults(&http.Transport{
3527
TLSClientConfig: &tls.Config{
3628
ServerName: serverName,
3729
},
3830
})
3931

32+
if len(caData) == 0 && len(certData) == 0 && len(keyData) == 0 {
33+
// reload system cert pool in case trusted-ca-bundle changed
34+
systemCertPool, err := x509.SystemCertPool()
35+
if err != nil {
36+
return nil, err
37+
}
38+
transport.TLSClientConfig.RootCAs = systemCertPool
39+
return transport, nil
40+
}
41+
42+
if (len(certData) == 0) != (len(keyData) == 0) {
43+
return nil, errors.New("cert and key data must be specified together")
44+
}
45+
4046
if len(caData) != 0 {
4147
roots := x509.NewCertPool()
4248
if ok := roots.AppendCertsFromPEM(caData); !ok {

0 commit comments

Comments
 (0)