Skip to content

Add api-proxy CA certificate support - #7816

Merged
lpcox merged 3 commits into
mainfrom
copilot/api-proxy-trust-private-ca
Aug 28, 2026
Merged

Add api-proxy CA certificate support#7816
lpcox merged 3 commits into
mainfrom
copilot/api-proxy-trust-private-ca

Conversation

Copilot AI commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Custom api-proxy upstream targets can use TLS certificates chained to private or corporate CAs, but the sidecar had no way to extend Node’s trust store. This adds a supported CA path for api-proxy without disabling certificate verification.

  • Configuration + CLI

    • Adds apiProxy.caCert to AWF config.
    • Adds --api-proxy-ca-cert <path> CLI plumbing.
  • Sidecar wiring

    • Bind-mounts the host CA file read-only into api-proxy at:
      /usr/local/share/ca-certificates/awf-upstream-ca.crt
    • Sets NODE_EXTRA_CA_CERTS to that mounted path so Node trusts the additional CA alongside built-in roots.
  • Schema, tests, docs

    • Updates config schema and generated runtime schema.
    • Adds focused coverage for config mapping, validation, type composition, build config, and Docker Compose output.
    • Documents the new flag and sidecar environment behavior.

Example:

apiProxy:
  caCert: /etc/ssl/certs/corporate-ca.crt
  targets:
    openai:
      host: llm-router.internal.example.com

Equivalent CLI:

awf \
  --openai-api-target llm-router.internal.example.com \
  --api-proxy-ca-cert /etc/ssl/certs/corporate-ca.crt \
  --allow-domains llm-router.internal.example.com \
  -- command

Copilot AI changed the title [WIP] Add support to trust private CA for custom upstream target Add api-proxy CA certificate support Aug 28, 2026
Copilot AI requested a review from lpcox August 28, 2026 04:23
@lpcox
lpcox marked this pull request as ready for review August 28, 2026 04:25
Copilot AI balanced review requested due to automatic review settings August 28, 2026 04:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds private/corporate CA trust for custom API proxy upstreams without disabling TLS verification.

Changes:

  • Adds config and CLI plumbing for apiProxy.caCert.
  • Mounts the CA into API proxy containers and configures NODE_EXTRA_CA_CERTS.
  • Updates schemas, tests, and documentation.
Show a summary per file
File Description
src/types/api-proxy-routing-options.ts Adds the CA option type.
src/types/api-proxy-options.test.ts Tests type composition.
src/services/api-proxy-service-config.ts Adds the read-only CA mount.
src/services/api-proxy-service-config.test.ts Tests Compose CA wiring.
src/services/api-proxy-env-config.ts Sets NODE_EXTRA_CA_CERTS.
src/schema.test.ts Covers valid schema usage.
src/config-mapper.ts Maps file configuration.
src/config-file.ts Adds the file-config field.
src/config-file-validation.test.ts Tests field type validation.
src/config-file-mapping.test.ts Tests config mapping.
src/commands/build-config.ts Propagates the resolved option.
src/commands/build-config.test.ts Tests option propagation.
src/cli-options.ts Adds the CLI flag.
src/awf-config-schema.json Updates the runtime schema.
docs/awf-config.schema.json Updates the canonical schema.
docs/awf-config-spec.md Documents config mapping.
docs/api-proxy-sidecar.md Documents the environment variable.
docs-site/src/content/docs/reference/cli-reference.md Documents CLI usage.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 18/18 changed files
  • Comments generated: 1
  • Review effort level: Balanced

[
// Mount log directory for api-proxy logs
`${apiProxyLogsPath}:/var/log/api-proxy:rw`,
...(config.apiProxyCaCert ? [`${config.apiProxyCaCert}:${API_PROXY_UPSTREAM_CA_CERT_CONTAINER_PATH}:ro`] : []),
@lpcox

lpcox commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback

Copilot AI commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address review feedback

Addressed in commit 5b0d7c1: relative CA paths are resolved from the invocation directory, and empty, missing, or non-file paths now fail with actionable errors before the Compose bind mount is emitted. Added focused coverage for normalization and rejection cases.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@copilot Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@github-actions

Copy link
Copy Markdown
Contributor

Documentation Preview

Documentation build failed for this PR. View logs.

Built from commit c6a4462

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

🔌 Service connectivity validated by Smoke Services

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

🛡️ Smoke Copilot Network Isolation confirmed the egress allowlist is enforced. ✅

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • example.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "example.com"

See Network Configuration for more information.

🛡️ Egress verdict from Smoke Copilot Network Isolation

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Smoke Gemini reports failed. Facets need polishing...

💎 Faceted by Smoke Gemini

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude passed

Generated by Smoke Claude for #7816

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

📰 VERDICT: Smoke Docker Sbx has concluded. All systems operational. This is a developing story. 🎤

📰 BREAKING: Report filed by Smoke Docker Sbx

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Security Guard has started processing this pull request

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.

Tested by Smoke Chroot

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅

📡 OTel tracing validated by Smoke OTel Tracing

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • registry.npmjs.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "registry.npmjs.org"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex

@github-actions

Copy link
Copy Markdown
Contributor

EGRESS_RESULT allow=pass deny=pass

✅ Allowed domain (github.com) reachable: allowed=200
✅ Blocked domain (example.com) denied: 403 proxy tunnel failure

Overall: PASS

@lpcox

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • example.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "example.com"

See Network Configuration for more information.

🛡️ Egress verdict from Smoke Copilot Network Isolation
Add label ready-for-aw to run again

@github-actions github-actions Bot added the smoke-copilot-network-isolation Copilot network-isolation egress smoke test label Aug 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Claude Engine Validation

Check Status
API ✅ PASS
GitHub CLI ✅ PASS
File ✅ PASS

Overall result: PASS

Generated by Smoke Claude for #7816 · claude · haiku45 · 32.7 AIC · ⊞ 4.5K ·
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: GitHub Actions Services Connectivity

  • Redis PING: ❌ (Temporary failure in name resolution)
  • PostgreSQL pg_isready: ❌ (no response)
  • PostgreSQL SELECT 1: ❌ (could not translate host name)

Overall: FAILhost.docker.internal did not resolve from the AWF sandbox.

🔌 Service connectivity validated by Smoke Services
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Smoke Test: Copilot BYOK (Direct) Mode

GitHub MCP Testing — MCP connected, PR list verified
GitHub.com Connectivity — HTTP 200
File Write/Read Test — smoke-test-copilot-byok.txt exists
BYOK Inference Test — Agent responding via api-proxy → api.githubcopilot.com

Status: ✅ PASS
Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY) via api-proxy.

🔑 BYOK report filed by Smoke Copilot BYOK
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot Engine@lpcox

Overall: PASS

📰 BREAKING: Report filed by Smoke Copilot
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Docker Sbx Smoke Test

  • ✅ GitHub MCP connectivity (list_pull_requests OK)
  • ✅ GitHub.com connectivity (HTTP 200)
  • ✅ File write/read test

Overall: PASS

cc @lpcox

📰 BREAKING: Report filed by Smoke Docker Sbx
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Chroot Version Comparison

Runtime Host Version Chroot Version Match?
Python Python 3.12.14 Python 3.12.14 ✅ YES
Node.js v24.19.0 v22.23.2 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Overall: FAILED — Node.js version mismatch between host and chroot environment. smoke-chroot label not added.

Tested by Smoke Chroot
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: API Proxy OTel Tracing — results:

  1. ✅ Module Loading — otel.js loads; isEnabled: true; exports startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled, _provider, ... and internal helpers.
  2. ✅ Test Suite — 3 suites / 68 tests passed (otel.test.js, otel-fanout.test.js, otel-workload-identity.test.js). Note: the workflow step uses the deprecated Jest flag --testPathPattern, which errors under the installed Jest version (needs --testPathPatterns); re-running with the correct flag confirms all 68 tests pass — CI step output itself may show a config error, not a real test failure.
  3. ✅ Env Var Forwarding — env-passthrough.ts forwards GITHUB_AW_OTEL_TRACE_ID/GITHUB_AW_OTEL_PARENT_SPAN_ID to the agent; api-proxy-env-config.ts forwards GH_AW_OTLP_ENDPOINTS, OTEL_EXPORTER_OTLP_ENDPOINT, and both trace-context vars to api-proxy.
  4. ✅ Token Tracker Integration — token-tracker-http.js contains onUsage (4 references) as the OTEL hook point.
  5. ⚠️ OTEL Diagnostics — no otel.jsonl was found under /tmp/gh-aw/sandbox/firewall/logs/api-proxy-logs/ for this run (only token-usage.jsonl, token-tracker-audit.jsonl, models.json), so no spans were exported during this smoke run — expected since no live API traffic through the sidecar occurred in this workflow invocation.

Overall: all core OTEL integration points verified; no unexpected failures. Recommend fixing the Jest flag (--testPathPattern--testPathPatterns) in the workflow to avoid a spurious CI error message.

📡 OTel tracing validated by Smoke OTel Tracing
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

fix: validate api proxy CA certificate paths
fix: add api proxy upstream CA option
GitHub MCP: ❌
safeinputs-gh: ❌
Playwright: ✅
File write/read: ✅
Build AWF: ✅
Discussion: ❌
Overall: FAIL

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • registry.npmjs.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "registry.npmjs.org"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia 1/1 passed ✅ PASS
Bun hono 1/1 passed ✅ PASS
C++ fmt N/A ✅ PASS
C++ json N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world N/A (ran, "Hello, World!") ✅ PASS
.NET json-parse N/A (ran successfully) ✅ PASS
Go color ok ✅ PASS
Go env ok ✅ PASS
Go uuid ok ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx All tests passed ✅ PASS
Node.js execa All tests passed ✅ PASS
Node.js p-limit All tests passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Note: Java's Maven local repository (~/.m2/repository) was not writable by the runner user (pre-existing permission issue, root-owned .m2 dir); tests were run with -Dmaven.repo.local pointed at a writable temp directory to work around it. Everything else ran as specified with no issues.

Generated by Build Test Suite for #7816 · copilot · auto · 40.8 AIC · ⊞ 12K ·
Add label ready-for-aw to run again

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

api-proxy: no way to trust a private CA for a custom upstream target (the agent and cli-proxy sidecars already have one)

3 participants