Skip to content

feat: Add CA certificate bundle support for builds#3751

Open
Itx-Psycho0 wants to merge 5 commits into
knative:mainfrom
Itx-Psycho0:feat/ca-bundle-support
Open

feat: Add CA certificate bundle support for builds#3751
Itx-Psycho0 wants to merge 5 commits into
knative:mainfrom
Itx-Psycho0:feat/ca-bundle-support

Conversation

@Itx-Psycho0
Copy link
Copy Markdown
Contributor

This PR adds support for CA certificate bundles during function builds. Users behind corporate proxies with SSL inspection need this to build functions successfully.

The implementation adds three ways to specify a CA bundle:

  • CLI flag: func build --ca-bundle /path/to/ca-bundle.crt
  • Environment variable: FUNC_CA_BUNDLE=/path/to/ca-bundle.crt
  • In func.yaml under build.caCertBundle

When a CA bundle is provided, it gets mounted into the build container and the appropriate environment variables are set for different language runtimes (Python, Node.js, Go, Java, Rust, etc). This works with both pack and s2i builders.

The implementation validates that the CA bundle file exists before starting the build and mounts it read-only into the container. I set environment variables like SSL_CERT_FILE, REQUESTS_CA_BUNDLE, NODE_EXTRA_CA_CERTS and others so the various build tools and package managers can find the certificates.

Fixes #3721

Add support for specifying a CA certificate bundle file to use during
function builds. This is useful when building behind corporate proxies
with SSL inspection.

Changes:
- Add CACertBundle field to BuildSpec in func.yaml
- Add --ca-bundle CLI flag to build command
- Support FUNC_CA_BUNDLE environment variable
- Inject CA bundle into pack builder with appropriate env vars
- Inject CA bundle into s2i builder with appropriate env vars
- Set SSL_CERT_FILE, REQUESTS_CA_BUNDLE, NODE_EXTRA_CA_CERTS, etc.
- Mount CA bundle file into build containers

Fixes knative#3721
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 15, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Itx-Psycho0
Once this PR has been reviewed and has the lgtm label, please assign dsimansk for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow Bot requested review from dsimansk and jrangelramos May 15, 2026 17:15
@knative-prow knative-prow Bot added the size/M 🤖 PR changes 30-99 lines, ignoring generated files. label May 15, 2026
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 15, 2026

Hi @Itx-Psycho0. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@knative-prow knative-prow Bot added the needs-ok-to-test 🤖 Needs an org member to approve testing label May 15, 2026
@matejvasek
Copy link
Copy Markdown
Contributor

matejvasek commented May 15, 2026

This deserves a comprehensive integration testing.

@matejvasek
Copy link
Copy Markdown
Contributor

One of the adepts for testing could be our "private git repo" tests. Right now we are compiling special build image with our own CA. That should not be necessary now. We could use ordinary image with the new option.

@matejvasek
Copy link
Copy Markdown
Contributor

But that's not the only test. You should add multitude tests to verify various components respect the CA.

@matejvasek
Copy link
Copy Markdown
Contributor

@matejvasek
Copy link
Copy Markdown
Contributor

What happens if CA is out of three?

@matejvasek
Copy link
Copy Markdown
Contributor

What happens if path is relative vs. absolute

- Fix volume mount bug in pack builder where CA bundle was overwritten
- Use Paketo CA certificates buildpack binding for pack builder
- Handle relative vs absolute paths properly
- Resolve relative paths relative to function root
- Support paths outside function directory
- Mount CA bundle to fixed location in S2I builder
- Validate CA bundle file exists before build

Changes based on feedback from matejvasek:
- Pack builder now uses standard Paketo ca-certificates binding
- Creates temp directory with proper binding structure
- Both builders handle relative/absolute paths correctly
- Paths are resolved and validated before build starts
Auto-generated by ./hack/update-codegen.sh
Don't modify f.Build.Mounts directly. Instead, create a local copy
of the mounts slice and add the CA bundle mount to the copy. This
prevents potential race conditions when the function struct is
shared across goroutines in tests.

This should fix the CI test failures.
@knative-prow knative-prow Bot added size/L 🤖 PR changes 100-499 lines, ignoring generated files. and removed size/M 🤖 PR changes 30-99 lines, ignoring generated files. labels May 15, 2026
Generated by 'make schema-generate' to include the new caCertBundle
field in BuildSpec. This is required for CI verification checks.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

❌ Patch coverage is 12.00000% with 66 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.90%. Comparing base (c0d60c2) to head (dfc8b06).

Files with missing lines Patch % Lines
pkg/buildpacks/builder.go 8.69% 40 Missing and 2 partials ⚠️
pkg/s2i/builder.go 0.00% 23 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3751      +/-   ##
==========================================
- Coverage   57.06%   56.90%   -0.16%     
==========================================
  Files         181      181              
  Lines       21144    21211      +67     
==========================================
+ Hits        12065    12070       +5     
- Misses       7855     7915      +60     
- Partials     1224     1226       +2     
Flag Coverage Δ
e2e 35.82% <12.00%> (-0.10%) ⬇️
e2e go 31.39% <14.03%> (-0.08%) ⬇️
e2e node 27.19% <14.03%> (-0.07%) ⬇️
e2e python 31.76% <14.03%> (-0.08%) ⬇️
e2e quarkus 27.31% <14.03%> (-0.07%) ⬇️
e2e rust 26.71% <14.03%> (-0.06%) ⬇️
e2e springboot 25.23% <14.03%> (-0.06%) ⬇️
e2e typescript 27.29% <14.03%> (-0.07%) ⬇️
e2e-config-ci 28.24% <14.03%> (-0.07%) ⬇️
integration 17.29% <0.00%> (-0.06%) ⬇️
unit macos-14 44.94% <14.03%> (-0.12%) ⬇️
unit macos-latest 44.94% <14.03%> (-0.12%) ⬇️
unit ubuntu-24.04-arm 45.19% <12.00%> (-0.13%) ⬇️
unit ubuntu-latest 45.89% <14.03%> (-0.12%) ⬇️
unit windows-latest 44.98% <14.03%> (-0.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ok-to-test 🤖 Needs an org member to approve testing size/L 🤖 PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Insert CA cert bundle during build to deal with transparent proxy

2 participants