Skip to content

Commit 0f9b3d2

Browse files
committed
SHIP-0042: Trusted certificates
Proposal to add a Shipwright feature to use trusted certificates in Build steps. Signed-off-by: Sayan Biswas <sayan-biswas@live.com>
1 parent 2587381 commit 0f9b3d2

File tree

1 file changed

+164
-0
lines changed

1 file changed

+164
-0
lines changed

ships/0042-trusted-certificates.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
---
2+
title: trusted-certificates
3+
authors:
4+
- "@sayan-biswas"
5+
reviewers:
6+
- TBD
7+
approvers:
8+
- TBD
9+
creation-date: 2025-11-11
10+
last-updated: 2025-12-11
11+
status: provisional
12+
see-also:
13+
replaces:
14+
superseded-by: []
15+
---
16+
17+
# SHIP-0042: Trusted Certificates
18+
19+
## Release Signoff Checklist
20+
21+
- [ ] Enhancement is `implementable`
22+
- [ ] Design details are appropriately documented from clear requirements
23+
- [ ] Test plan is defined
24+
- [ ] Graduation criteria for dev preview, tech preview, GA
25+
- [ ] User-facing documentation is created in [docs](/docs/)
26+
27+
## Open Questions [optional]
28+
29+
30+
## Summary
31+
32+
This proposal aims to enhance Shipwright by allowing users to add user certificates in the build container's
33+
system trust store by extending the Build APIs to let user define a list of Kubernetes Secrets/ConfigMaps, which will
34+
hold the certificate data and will be added to the trust store.
35+
This capability is essential for scenarios requiring access to external resources like self-signed
36+
certificates for Git/image registries or other necessary build artifacts, independent of BuildStrategy
37+
definitions, overcoming a current limitation where all volumes must be pre-defined or overridable via the strategy.
38+
39+
## Motivation
40+
41+
Currently, Shipwright Builds face challenges when needing to utilize resources like self-signed
42+
certificates for interacting with private Git repositories or image registries.
43+
44+
### Goals
45+
46+
- Extend `Build` and `BuildRun` resources API to declare a Secrets/ConfigMaps that holds certificate data.
47+
- Ensure these certificates are loaded and accessible to all primary containers involved
48+
in executing the build steps throughout the lifecycle of the build's execution Pod.
49+
50+
### Non-Goals
51+
52+
What is out of scope for this proposal?
53+
Although users can create their own ConfigMap and Secret with the certificates data, we have few options which automate this distribution of trust anchors:
54+
- Using [TrustManager](https://cert-manager.io/docs/trust/trust-manager/) generate trust bundle and mount it in workload during reconciliation.
55+
- Use [Cluster trust bundles](https://kubernetes.io/docs/reference/access-authn-authz/certificate-signing-requests/#cluster-trust-bundles) and [clusterTrustBundle projected volumes](https://kubernetes.io/docs/concepts/storage/projected-volumes/#clustertrustbundle) to mount it in workload.
56+
57+
## Proposal
58+
59+
### User Stories
60+
61+
#### Using self-signed certificates
62+
63+
As a user, I want to use Git repositories or image registries that are secured with self-signed
64+
certificates. These certificates need to be accessible by the build process, potentially across
65+
multiple steps (e.g., source cloning, image push/pull).
66+
67+
### Implementation Notes
68+
69+
The current BuildRun APIs will be extended to support a list of certificates accepted as kubernetes Secret
70+
resources that should be loaded in the container's trust store.
71+
72+
```yaml
73+
apiVersion: shipwright.io/v1beta1 # Ensure this is the correct API group
74+
kind: Build
75+
metadata:
76+
namespace: test
77+
# ...
78+
spec:
79+
# ...
80+
certificate: # can define either a secret or a configmap
81+
mountPaths: # (optional) if not provided, common linux location will be used to mount
82+
- /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
83+
- /etc/pki/ca-trust/extracted/java/cacerts/bundle.jks
84+
secret: # can be either secret or configmap
85+
name: gitea-tls # name of the secret in the same namespace that holds the CA data
86+
key: tls.crt # key in the secret data to look for. We don't want to mount every key
87+
```
88+
89+
If no mount paths are specified, the CA bundle will be mounted on common locations is linux distributions.
90+
Reference: https://go.dev/src/crypto/x509/root_linux.go
91+
```text
92+
"/etc/ssl/certs/ca-certificates.crt", // Debian/Ubuntu/Gentoo etc.
93+
"/etc/pki/tls/certs/ca-bundle.crt", // Fedora/RHEL 6
94+
"/etc/ssl/ca-bundle.pem", // OpenSUSE
95+
"/etc/pki/tls/cacert.pem", // OpenELEC
96+
"/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem", // CentOS/RHEL 7
97+
"/etc/ssl/cert.pem", // Alpine Linux
98+
```
99+
100+
Consideration for mount point:
101+
- Certificate defines a CA Bundle.
102+
- User should provide the CA bundle in a secret or configmap in the same namespace as Build and BuildRun resource.
103+
- Priority of certificate spec: BuildRun >> Build
104+
- Use subPath: Sub paths will be used mount for single file injection. This method doesn't support auto-update of when secret is modified. In CI build context, this not relevant.
105+
- Environment Variables: Mount certain environment variables..
106+
- Node.js `NODE_EXTRA_CA_CERTS=/path/to/your/bundle.pem`
107+
- Python `REQUESTS_CA_BUNDLE`
108+
- Openssl `SSL_CERT_DIR` and `SSL_CERT_FILE`
109+
- TBD
110+
- Java: Use the jks or pkcs12 target in your trust-manager Bundle spec and mount it to the Java cacerts path `$JAVA_HOME/lib/security/cacerts`.
111+
- Mount points should not overwrite a symlink.
112+
113+
Note:
114+
<br> Debian-based (Ubuntu, Debian, Alpine): Use `/etc/ssl/certs/ca-certificates.crt`.
115+
<br> Red Hat-based (UBI, RHEL, Fedora): Use `/etc/pki/tls/certs/ca-bundle.crt`.
116+
117+
118+
If a certificate with the same name is defined at multiple levels, the following precedence will apply
119+
for its definition (e.g., which Secret or ConfigMap to use):
120+
121+
- BuildRun.spec.certificate (highest precedence) >> Build.spec.certificate
122+
- For new, directly mounted volumes, a mountPath and subPath must be specified.
123+
- Volume names to have postfix (hash or randon) to avoid conflict
124+
- Standard Kubernetes validation for the source secret will apply.
125+
- A certificate definition can have either Secret and ConfigMap reference.
126+
- Validation will be done to check if the referenced resource exists in the cluster and namespace.
127+
- Syntax validation of certificate data in the secret/configmap to be done.
128+
129+
### Test Plan
130+
131+
TBD
132+
133+
### Release Criteria
134+
135+
TBD
136+
137+
#### Upgrade Strategy [if necessary]
138+
139+
This API change doesn't break any existing functionalities. Upgrade strategy is not relevant.
140+
141+
### Risks and Mitigations
142+
143+
- File injection into the operating system's trust store will replace the existing CA bundle which might have CAs for several public domains.
144+
- This can be solved by mounting the certificates in common places (different linux distros) which provide to mount user certs and then allow OS to index and place it in the right place.
145+
- Instead of replacing the CA bundle in the system, append the content of the new CA to the existing one.
146+
147+
## Drawbacks
148+
149+
- If we don't want to replace the existing certificate, then we have to mount the system's certificate directory (eg: /etc/ssl/cert) as a volume, since we have ReadOnlyRootFileSystem enabled.
150+
151+
## Alternatives
152+
153+
- Define volumes directly in the Strategy and allow Build to override it. Mount volumes to git and image-push containers and user manages everything from defining secret and mounting it to correct location.
154+
155+
## Infrastructure Needed [optional]
156+
157+
Use this section if you need things from the project. Examples include a new subproject, repos
158+
requested, GitHub details, and/or testing infrastructure.
159+
160+
Listing these here allows the community to get the process for these resources started right away.
161+
162+
## Implementation History
163+
164+
- 2025-11-11: Initial Draft

0 commit comments

Comments
 (0)