Configure Custom Certificates
This guide is for cluster administrators who need to configure PAC to trust self-signed certificates or custom CA certificates for Git providers.
Note: Throughout this document, <pac-namespace> or tekton-pipelines refers to the namespace where PAC is deployed. The default namespace is tekton-pipelines, but you can customize it via targetNamespace in the OpenShiftPipelinesAsCode CR. Replace <pac-namespace> or tekton-pipelines with your actual namespace name if different.
This guide explains how to configure PAC to work with Git hosting services that use self-signed certificates or custom CA certificates. This configuration applies to all Git providers (GitHub Enterprise, GitLab self-hosted, Bitbucket Server, etc.).
TOC
Prerequisites
Before configuring custom certificates, ensure you have:
- PAC component deployed
- Administrator access to the cluster
- Access to the CA certificate file
- Ability to modify the
OpenShiftPipelinesAsCodeCR or theTektonConfigCR
Overview
When your Git hosting service uses self-signed certificates or certificates signed by a custom CA, PAC's controller pods need to trust these certificates to successfully connect to the Git service. This requires:
- Creating a ConfigMap with the CA certificate
- Mounting the certificate in PAC controller pods
- Configuring Git to use the certificate
Step 1: Prepare the CA Certificate
Obtain the CA certificate file from your Git hosting service administrator or from your organization's certificate authority.
Common locations for CA certificates:
- Self-hosted GitLab: Usually available in the GitLab installation or from your organization's CA
- GitHub Enterprise: Available from your GitHub Enterprise Server administrator
- Bitbucket Server: Available from your Bitbucket Server administrator
The certificate file should be in PEM format:
Step 2: Create ConfigMap with CA Certificate
Create a ConfigMap containing the CA certificate in the PAC namespace (default: tekton-pipelines, replace with your actual PAC namespace if different):
Method 1: From File
Example output:
Method 2: Manual Creation
Create a YAML file git-ca-cert-configmap.yaml:
Apply it:
Example output:
Note: Replace <your-ca-certificate-content> with the actual certificate content.
Step 3: Mount Certificate in PAC Controller
Mount the certificate in the PAC controller pods by updating the OpenShiftPipelinesAsCode CR or the TektonConfig CR.
For OpenShiftPipelinesAsCode CR
If you're using the OpenShiftPipelinesAsCode CR:
For TektonConfig CR
If you're using TektonConfig CR (for OpenShift deployments):
Important:
- The certificate is mounted at
/etc/ssl/certs/git-ca.crtin the container - Environment variables
GIT_SSL_CAINFOandSSL_CERT_FILEtell Git to use this certificate - After updating the CR, the Operator will automatically restart the PAC controller pods
Step 4: Apply Configuration
Apply the updated CR:
Example output:
Wait for the PAC controller pods to restart:
Example output:
Step 5: Verify Certificate Configuration
Check Certificate is Mounted
Verify the certificate is mounted in the PAC controller pod:
Example output:
You should see the volume configuration showing the certificate is mounted.
Check PAC Controller Logs
Check the PAC controller logs for any certificate-related errors:
If configured correctly, you should not see SSL/TLS certificate errors in the logs.
Test with a Repository
Trigger a test pipeline from a repository hosted on your Git service:
Example output:
Check if the PipelineRun is created successfully:
Example output:
Troubleshooting
Check if Certificate is Not Trusted
Problem: PAC still cannot connect to your Git service due to certificate issues.
Solutions:
- Verify certificate format: Ensure the certificate is in PEM format with proper BEGIN/END markers
- Check certificate path: Verify the certificate is mounted at the correct path
- Verify environment variables: Ensure
GIT_SSL_CAINFOandSSL_CERT_FILEare set correctly - Check ConfigMap: Verify the ConfigMap exists and contains the certificate:
Example output:
Check if Certificate is Expired
Problem: The CA certificate has expired.
Solutions:
-
Obtain a new CA certificate from your certificate authority
-
Update the ConfigMap:
Example output:
-
Restart PAC controller pods:
Wrong Certificate
Problem: Using the wrong CA certificate for your Git service.
Solutions:
- Verify you're using the correct CA certificate for your Git hosting service
- For self-hosted services, obtain the certificate directly from the service
- For enterprise services, contact your administrator for the correct certificate
Pod Not Restarting
Problem: PAC controller pods are not restarting after updating the CR.
Solutions:
-
Check CR status:
Example output:
-
Check Operator logs:
Example output (example log entries):
- Manually restart the deployment:
Multiple Certificates
If you need to trust multiple CA certificates (e.g., multiple Git hosting services), you can:
Option 1: Combine Certificates in Single ConfigMap
Combine multiple certificates in a single file:
Option 2: Use Separate ConfigMaps
Use separate ConfigMaps and mount them in different locations, then configure Git to use a certificate bundle:
Create a certificate bundle by combining all certificates into a single file.
Best Practices
1. Certificate Management
- Store securely: Keep CA certificates in secure storage
- Version control: Track certificate changes in version control (if not sensitive)
- Documentation: Document which certificates are used and their sources
- Expiration tracking: Monitor certificate expiration dates
2. Security
- Least privilege: Only grant access to necessary certificates
- Rotation: Rotate certificates regularly
- Validation: Validate certificates before deploying
3. Troubleshooting
- Test first: Test certificate configuration with a test repository before applying to production
- Monitor logs: Regularly check PAC controller logs for certificate errors
- Backup: Keep backup copies of working certificate configurations
Next Steps
- Configure Authentication for Private Repositories - Configure authentication for private repositories
- Manage PAC Component - Learn about managing PAC deployment
- Configure GitLab Repository - GitLab-specific configuration guide
- Common Issues - Troubleshooting guide