Replacing the CA Bundle Certificate
This guide explains how to update the cluster-wide CA bundle to trust custom certificate authorities, which is necessary when using custom certificates for the API server or ingress controllers.
Prerequisites
- Access to the ARO cluster with cluster-admin privileges
- The
oc
CLI tool installed and configured - Your custom CA certificate file (e.g.,
ca-bundle.crt
)
Update the CA Bundle
1. Create a ConfigMap with your CA certificate
Create a ConfigMap in the openshift-config
namespace containing your custom CA bundle:
IMPORTANT
If using windows, ensure the certificate file uses LF
line endings. Convert from CRLF
to LF
if needed.
Bash:
oc create configmap custom-ca \
--from-file=ca-bundle.crt=/path/to/ca-bundle.crt \
-n openshift-config
Alternative - Using a YAML manifest:
apiVersion: v1
kind: ConfigMap
metadata:
name: custom-ca
namespace: openshift-config
data:
ca-bundle.crt: |
-----BEGIN CERTIFICATE-----
Your custom CA certificate bundle content here
-----END CERTIFICATE-----
Apply the manifest:
oc apply -f custom-ca-configmap.yaml
2. Update the cluster-wide proxy configuration
Patch the cluster proxy configuration to reference the newly created ConfigMap:
oc patch proxy/cluster \
--type=merge \
--patch='{"spec":{"trustedCA":{"name":"custom-ca"}}}'
oc patch proxy/cluster --type=merge --patch '{\"spec\":{\"trustedCA\":{\"name\":\"custom-ca\"}}}'
3. Verify the configuration
Check that the proxy configuration has been updated:
oc get proxy/cluster -o yaml
Wait for the cluster operators to reconcile the changes:
oc get clusteroperators
Working with Certificate Chains
If you have a certificate file that contains multiple certificates (main certificate + chain), you may need to split them:
Split certificate chain from main certificate
Method 1 - Simple AWK script:
awk 'BEGIN{main=1} /BEGIN CERTIFICATE/{if(!first++){main=1}else{main=0}} {print > (main?"main_certificate.pem":"chain_certificates.pem")}' aro-prd-we.pem
Method 2 - More verbose AWK script:
awk '
/^-----BEGIN CERTIFICATE-----$/ {
cert_type = (++cert_count == 1) ? "main_certificate.pem" : "chain_certificates.pem";
}
{
if ($0 ~ /^-----BEGIN CERTIFICATE-----$/ || $0 ~ /^-----END CERTIFICATE-----$/ || $0 ~ /^[A-Za-z0-9\/+]+=*$/) {
print > cert_type;
}
}
' aro-prd-we.pem
Combine certificates
If you need to create a full certificate chain:
cat main_certificate.pem chain_certificates.pem > full_chain.pem
Convert certificate format
If needed, convert the chain certificate to PEM format:
openssl x509 -in chain_certificates.pem -out chain_certificates_fixed.pem -outform PEM
Create ConfigMap from chain certificate
To use only the chain certificates for the CA bundle:
oc create configmap custom-ca \
--from-file=ca-bundle.crt=chain_certificates.pem \
-n openshift-config
Troubleshooting
Verify certificate contents:
openssl x509 -in ca-bundle.crt -text -noout
Check ConfigMap:
oc get configmap custom-ca -n openshift-config -o yaml
View cluster proxy status:
oc describe proxy/cluster